In Britain at least a lot of it stretches back to the English Civil War. The Royal Navy is known as the 'senior service' because naval combat and gunnery requires a relatively high degree of professionalism and training as opposed to a lot of land warfare, and so it made sense to have a permanent standing fleet with purpose built warships. This had to an extent been the case since the 9th century but was really formalised around the time of the 1st Anglo-Dutch War. A lot of the work behind formally establishing the Royal Navy can be seen in Samuel Pepys' diaries.
Outside of the artillery and the King's household regiments, however, most land forces were essentially county militias, called into action by the nobility when necessary and backed by a small core of professional soldiery. During the confusion of the English civil war, both sides had a problem with regimental commanders switching sides in the middle of battles, and so Parliament created the New Model Army, essentially the first professional standing army in England, which would be under its command rather than dependent on the whims of the nobility. Even after the restoration, this army was maintained, but because it was initially raised by parliament, it never became the Royal Army like the Royal Navy.
Over time, however, as new regiments and divisions and so on were created, some of them were raised by royal order or given a royal title as a sign of prestige, such as when the Tank Regiment became the Royal Tank Regiment. Most of the original 'county' regiments, however, lack the royal designation.
Richard Holmes, Redcoat: The British Soldier in the Age of Horse and Musket
Frank Knight, General at Sea: The Life of Admiral Robert Blake