The Irish province led 10-3 at the interval after Craig Ronaldson converted Jake Heenan's try and scored a penalty to cancel out one in reply from Rhys Patchell.
But Patchell had the last say when he converted Joaquin Tuculet's try in time added-on to give Cardiff their first win over an Irish province this season.
And Lam felt Connacht had themselves to blame for failing to make their first-half possession count.
"We should have been 30 points ahead, and we blew chances, we just needed to be patient," he told RTÉ Sport.
"We were clearly the dominant team there, and we just weren't executing as well as we could have.
"And that was my biggest worry; they showed last time, if you give them time and space, they can truck it up the middle. We should have been way gone before that.
"We don't have the most experienced players, but guys work hard for each other, and we created so many opportunities, it was disappointing that we didn't finish.
"But we were right in that game, and it's just gutting the way we finished."
Connacht stay sixth in the GUINNESS PRO12 table but Lam insisted his team would be able to use the disappointing defeat to their advantage in the coming weeks.
"I've never seen a changing-room like that. We've said we've got to use it. There's nothing we can do about it, except go through the process, keep people accountable," he added.
"And then on the back of that, move on. We've got a week to get over it, and it's obviously difficult, and then we'll get back, and we've got to prepare for Munster."
Follow us on Facebook, join the conversation on Twitter, sign up to our YouTube channel for extensive match highlights and sign up for our newsletter for regular updates on the GUINNESS PRO12
Guinness PRO12
Suite 208, Alexandra House,
The Sweepstakes
Ballsbridge, Dublin 4, Ireland