I am using an Arduino UNO with a dual relay for controlling a motor to turn both ways.
When my arduino is supplied by the usb port the relay works fine.
When I am using a 12Vdc transformer to supply both the arduino and the motor my relay’s one side goes crazy and it goes on and off randomly.
I ve seen that a lot of people had similar problems and after a small research I ended up buying an RC snubber from amazon
I tried connecting it with IN1 and GND of the relay and in parallel with the transformers output but either helped out.
Is there any suggestions on how to connect it??
First a transformer is an AC device. You are likely using a commonly called wall wart or 12 VDC supply. If you are using strictly a transformer which some wall warts are that is not good and can damage anything designed for DC. Your Arduino and anything DC expect a clean DC and I have no clue what your supply is or how things are wired. The fact things work apparently fine using USB power but don't using whatever your external power actually is leads me to believe your external power source is not what it needs to be or should be.
That does not address the real problem, but you need to post links to the all parts and a photo of a hand drawn wiring diagram, for forum members to determine what that might be.
Links please. Especially to the thing driving the motor.
That looks like a relay, in which case you should completely isolate the Arduino power supply from the motor supply and ground. What you are doing now may produce large voltage spikes that could destroy the Arduino.