I guess this was for a similar same reason as the famous Tannenberg gun was found in a well belonging to the ruins of a castle destroyed in 1399.
Just because a certain place was destroyed in a certain year, the possibility that some decades later somebody came by those ruins and probably tried to explore them cannot be a priori
excluded. Then it might have been the case that our visitor either stumbled and fell, the handgonne falling deep down under the ruins, or that he was surprised by somebody else and lost his gun in combat.
Anyway, there is no doubt that both the Tannenberg gun and the Otepää gun were actually not made before the first half of the 15th century, ca. 1420-30 by the earliest, as I pointed out in a former post. So how it came they were both found between earlier ruins is completely left to speculation - dissatisfying as it may be.