Well, maybe I'm being a little harsh. Most bag makers are pretty careful to test their bags to ensure they perform more or less as advertised. But how do they test them? And to what degree? There it gets difficult (and mired in the top-secret world of proprietary data). Some use heated dummies that can measure how much warmth escapes from the bag at different temperatures. Others figure the insulating value of, say, a one-inch thickness of fill material, then calculate warmth based on the use of three inches of the same stuff.
The problem with sleeping bags, though, is not that the temp ratings are necessarily inaccurate (although some surely are), it's that human beings vary so widely. I, for instance, have a 30-degree bag made by Marmot. I've slept in it down to the mid-20swearing some long underwearand have snoozed just fine. I've also slept in it when it has been closer to the mid-30s, and felt less than warm. Why? Probably lots of reasons: how tired I was, whether I felt chilly before going to bed, whether the bag was somehow a little damp, even what I'd eaten before turning in. There are some people for whom a 30-degree bag would work well into the teens. For others, they could use it when it's 40 degrees out and feel as if they're freezing to death. It could be your bag is not rated accurately. It could be that you sleep a little "cold." It could be that a better sleeping pad (the ground is often what chills people) would make a huge difference.
As a further wild card thrown into this clearly unscientific equation, bags change with time. The fill in down bags may get dirty and lose some loft, while essentially all synthetic bags will lose some loft as time goes by.
None of which is meant to take bag makers off the hook. The Great Race among them is to make the lightest, warmest bag for the least green. Obviously, there's incentive to fudge a little and hope that no one notices. But to come up with a truly accurate temp rating for a bag is, in a nutshell, impossible.