They were awarded based on the spoils system
The spoils system was the idea that the victor takes the spoils of war, that is, the person who won the presidency can fire all employees that don't support him and put his own people into positions of power in federal agencies and organizations. After that, the merit system was introduced that ended this corrupt practice.