Confusing L298n module problem

You need to make a simple pencil drawing showing exactly how you have everything connected and post a photo of your drawing. See this Simple Image Guide

Also post a link to the datasheet for the specific L298 module you are using.

A very wild guess (very wild) is that you don't have good GND connection to the Arduino

...R