Regarding weight:
If you go through a check-in desk (rather than online, mobile or kiosk check-in), then as thethey have the scale right there they could ask you goto put the bag on the scale to check, especially if the bag looks a bit large or it looks heavy (you are straining to keep it on your shoulder, or when picking it up or dropping it down).
This happened to me a few times back when I used to fly Aer Lingus on the CDG-DUB route and they had a 7 kg limit for cabin bags.
I remember some airlines having the same sizing device but with an added scale built-in, so they could check both size and weight at the same time:
Don't remember having seen one of those recently though.
Regarding size:
Note that the sizing device varies between airlines. Some are just a bunch of tubes like the one on the picture posted by Spehro Pefhany, which leaves quite a bit of flexibility especially for "soft" bags, wheels, pockets, handles, etc. while others have rigid flat sizes, which leaves a lot less flexibility:
Wheels, pockets and handles can make the difference between "it fits" and "it doesn't, go to the desk to check your luggage and pay the at-the-airport checked-luggage fare".
In general, low-cost carriers and any carriers with restrictive luggage policies or fares without checked luggage are more aggressive when it comes to checking weight and size limits.
Also, limits are enforced more strictly when the flight is full and/or it has more people carrying lots of hand luggage (e.g. around the winter holidays) as space is scarce.