I see in various archives pictures of soliders and sailors (mostly from the world wars but occasionally other conflicts) who have pets such as dogs, cats or rabbits. Could they, and if so, how did they balance the duties and mobility of being an active service member while also taking care of a pet?
It is difficult to generalize an answer to this question as the experience will vary enormously with both the type of pet and the type of active service but I can discuss a particular well known case from WW2 as the War Diary of VX13091 Private JB Moody has been researched and published at least twice, as
Horrie the Wog Dog, by Ion L. Idriess pub 1945, and
Horrie the War Dog, by Roland Perry pub 2013.
Moody served in the signals group of the 2nd A.I.F. 1st Machine Gun Battalion (a motor bike courier and radioman). He found Horrie, a smallish white terrier type stray dog in Egypt (wog being the A.I.F.'s term for arab) and it accompanied him in action in the war zones of the middle east, (Libya, Egypt, Greece-Crete, Palestine, Syria). When Japan entered the war and the unit was recalled for the defence of Australia the dog was smuggled back to Australia where some years later it was killed for being in breach of Australia's quarantine policy. In the second book listed above Perry claims that a different dog was surrendered to be killed.
In his diary Moody mentions encountering other similar pets, always dogs, in very similar circumstances.
To answer your particular questions; no, they were not permitted to keep pets, it was specifically against policy however while the pet was in the main care of one or two soldiers it would be known to the fellow soldiers in a unit who would take some responsibility for caring for it, obtaining food, smuggling it on and off troop transports in someone's back pack and particularly in notionally concealing it from higher command although he implies that immediate commanders were happy to wink at it so long as the appearance of concealment was made. The pet had the status of an unofficial unit mascot so care was shared and the dog accompanied the unit in action.
There wasn't anything unique about Horrie except that his carer managed to smuggle him back to Australia in breach of quarantine and he came to public notice in the fuss over his killing.