from what I understand, the UK's military mostly stayed loyalist in the lore
No, it was pretty split.
I think there's a tendency to look at the UoB lore, and by extension what's happening here in Gibraltar, while forgetting that in every civil war there's a great many people who do not decisively pick a side, but instead lean toward one or the other. Usually they do so for practical reasons, and favor whoever's able to protect their immediate interests, sometimes switching sides multiple times during the conflict. Sometimes many of those people are simply swept up in the moment, especially if they're young. Often they're a not-so-visible but powerful long-term asset behind whichever faction they back.
Again, I'm not the UoB dev, but presumably something as messy as a short-lived anarchist commune created by spontaneous revolution would have most of the population more concerned about getting shot, or where their next bread and water might be coming from, than who's a monarchist and who isn't. Many might expect the eventual restoration of order, and so go along with things out of fear. Others might have expected a different outcome when they signed on, or thought the revolution in Britian was already a done-deal. Some might've even gone along along just on the basis of providing a united front against Spanish intervention, which would have been made even more likely by the population and garrison fighting against itself.
Gibraltar is small enough that I think the right combination of misinformation and agitation is reasonably enough to lead to what it does here, even if only in the short term.