The issue that needs to be addressed is why the armies felt no loyalty to the Senate and the Republic in comparison to their generals.
The army had representation in the Republic through the Centuriate Assembly. The problem with the Centuriate Assembly is twofold: They were divided by wealth into 5 classes with equal voting rights, and they voted in order of wealth. Since the soldiers of the Marian army were generally poor, the vast majority of the army was in the lowest class of voting units, meaning that the majority of army controlled 20% of the vote, while the minority controlled 80% of the vote. And that 20% never even got to vote anyway, since all matters were determined before they even got to their votes.
So, change the system up, and the army will be more interested in and more capable of having their issues addressed through the constitutional system.
Oh, having some stake in the elections while they're out on campaign wouldn't hurt, either.