why do I dismount my mount when I attack

It despawns because you cannot use tools or weapons while in the DCU.

Unlike other mounts, players cannot use any tools or weapons while riding the Drill Mount.

source