The programming SPELL bothering people because it's not enough like coding is kind of funny. It's literally "a wizard did it," but you want to get hung up on the specifics in it? Okay then, here we go. Specifically, what he "coded" into this gun was for it to activate other spells for the transformation. Lolibaba told him the magic couldn't make objects do things they weren't already potentially capable of, so he made the object capable of it with one of his other Unlimited Spell WorksTM abilities. It's not "nonsensical" if it literally draws on his established ability kit.
Could you call it stupid, silly, overpowered, or a slew of other things? Sure, personally I think it was a waste of time going through all this. I would've just made him adapt in battles the old fashioned way, like how he actually defeated the Beastking in the first place. Making someone overpowered is one thing but continually handing them new stuff like this reminds me of how Superman got his powers and became one of the most boring motherfuckers in an entire multiverse, with the most contrived weaknesses to offset it all.