John Q. Adams, like Jefferson and the presidents before him could see that the country was becoming ever more divided.
I've written before that the issue of foreign sanctions on imported goods almost made the Northeast and his home state of Massachusetts secede early in the history of the country, long before slavery became the most divisive issue of the day.
As abolitionists in the North grew more determined and pro slavery elements in the South grew more divisive, he could see that there was a rift taking place between regional factions and interests that would tear the country apart.
If he had continued Jefferson and Madison's policies on relying heavily on state funded and run militias, it would have only accelerated the rift. Most of Q. Adams policies during his presidency sought to increase the power of the federal government and thus strengthen the national identity of Americans.
After his presidency, he became ever more anti slavery and in the last years of his life, he influenced Abe Lincoln who would later be president to use War Powers to eliminate slavery in the South when Civil War broke out.
"The preservation of the Union is to me what the destruction of Carthage was to Cato, the conclusion of every discourse."