Let me be even more clear that this was a warship, i.e., an armed ship built on a medium hull and containing no constructor, trade or mining modules. I placed this heavily armed and veteran frigate (it had over 200 hit points) on the base to protect it. In the first place, I was surprised the base was engaged instead of the ship. However, I was even more surprised when immediately after the base was destroyed, my warship became a new starbase (without any armament or other extra modules) on the resource. I never got the opportunity to move it.
Now, I have always noticed that a non-constructor ship cannot move into the same square as a resource because long ago I tried to "hold" a resource by placing the ship over it until my constructor could get there and claim the resource. It doesn't work. However, once a base is built there, ships can occupy the same square. With the destruction of the base, my non-constructor warship was occupying the same square as the resource so perhaps some internal rule had to sort that out and did so by just making my ship a base. I think a better solution would be to just have the warship or other non constructor ship moved aside from the resource. Of course, if the base is surrounded by enemy fleets that might not be possible either. Thus, I think the even better solution would be to just allow warships and other non constructor ships to occupy the same space as a resource without building any starbase.