Atmega 328 PU at 8Mhz and Motor Drivers

Hello All,
I'm trying to use Atmega 328 PU at 8Mhz mode to be used as a motor speed controller but I'm unable to keep it working as the motors also only need 5V. I'm connecting the motors to the same power source parallel to L293D and Atmega 328 PU power.

The circuit is failing to work whenever a motor is connected but working fine with LEDs.

While replicating this but connecting Arduino Board instead at Atmega 328PU it is functioning perfectly.

I need some help in understanding this.

Welcome @gudipudiramanakumar ! I may not be able to help you but I can point you in the right direction.

Post your schematics, board design, and photos of your device. Provide some explanations of the relations of the parts. If applicable, post a simple arduino code and describe what you want it to do and what it is actually doing.

And also: details of the motors used as well as the power supply.