Wales received three yellow cards in their opening two Six Nations encounters and were determined to keep on the straight and narrow against Italy.
They held on for a victory in Rome and despite not having anyone sent to the sin-bin Wales were still disappointed with their discipline.
They have now conceded 36 penalties in the Championship to date - more than any other side.
Wales face Ireland at the Millennium Stadium next weekend and Williams, who has twice toured with the Lions, is adamant his side will be punished if they continue to give needless penalties away.
"It's schoolboy stuff and we have to cut it out," said Williams. Discipline's still a major issue for us.
"The penalty count against Italy wasn't good enough. At international level you'll get punished and Italy could've won that game.
"Ireland play clever rugby, they put you under pressure, their good at the set-piece and look for turnovers. Hopefully we've learnt our lessons because Jonathan Sexton and Ronan O'Gara will make you pay."
Williams reckons the excessive penalty count is also having a negative effect on Wales' attacking flow.
"We're giving away key penalties in key areas and it's stopping us playing our usual game. When we're in good positions we feel under pressure, we go into our shell and stop playing rugby.
"We have a bit of a habit of winning ugly at the moment. But at the end of the day you look at results and it was a win.
"We've been guilty in the past of playing really well but losing. Hopefully against Ireland we can meet in the middle, play some good rugby and get the result."