It's not just you, we kinda just zipped right past the discovery stage and into here.
Magic tech has been an established thing in this world, it’s just that we haven’t seen much of it as they explained that it’s expensive to make and expensive to purchase the bigger contraptions. Remember how much it cost Alan to get taught how to make the items, and then how much he was able to sell them for? They weren’t cheap by any stretch of the imagination.
Also keep in mind that this is a king that’s laying siege to the territory, so it’s not out of the ordinary for a king to use his treasury to get the best toys for war.
As for your comment about the mines, it isn’t outside of the realm of possibility for them to know how to use a fancy bomb. Instead of using a fuse they have a “magic” button to press to trigger them, so it’s easy to see how knights wouldn’t be surprised.