If you are on mobile, I am not sure how these attacks get triggered, especially if you use auto-attack.
Based on my experiences playing on mobile (Android) and using auto-attack, it seems like the secondary move (which is a block if you're using a sword, other attack types if a dagger or a hammer) gets triggered
when you tap directly on a monster. I used to get super frustrated because I thought tapping on a monster meant to attack it in general. It does work, but in practice, I suspect using the secondary move is much more unwieldy on mobile than on a controller or keyboard. That said, I've reached perfection and can confidently take on the dangerous mines without needing it.
I also discovered that auto-attack will trigger and swing your sword at approaching monsters even while you are moving,
if the "follow your finger" mode is active. If you've tapped-to-move and are on your way to the tapped point (without you actually touching the screen) then you are vulnerable on the way.
For this reason, if I'm fighting monsters I start to move once and then just don't ever lift my finger. Only after I've cleared out enemies will I start tapping on rocks or nodes to pickaxe them.