I've had quite a few great homebrews (not necessarily my own; I maintain that you can't completely and objectively judge your own beer) and some bad ones. Likewise I've had some great commercial brews and some not-so-great ones.
Something that commonly goes unnoticed is the fact that not all commercial beer is "perfect". There seems to be some unstated impression that if something's commercially produced, it's a 50 point beer, period. So many times that's not the case. I don't care if Stone, Russian River, Victory, or Boston Beer makes it.
I could tell you about a porter that I had at an Oktoberfest that had so much diacetyl I was thinking about pouring it on popcorn. When I asked the brewer about it, he said "some people like that flavor".
And to further the point, as a homebrewer you could dump a batch if there was a flaw that didn't render the beer undrinkable; it's up to you. As a professional brewer, you may have to just acknowledge that it's not the best and hope that it still sells. Brewing a few hundred gallons costs a lot more than a $30 5-gallon batch.
Or, I could tell you about the few beers we had in BJCP class that, while they were commercial examples of their styles were still flawed: Saison Dupont was skunked, Negra Modelo was oxidized, etc. Was a good way to learn about flaws though.
A few months ago I bought a Köstritzer Schwarzbier (BJCP commercial example). Oxidized. A few years ago I bought a 6er of Lancaster Hop Hog. Infected!!! (to that end, my wife told me that BJCP class has ruined my taste for beer!
)
We all know there's many variables to brewing and professional brewers generally have more control over those variables brought about by equipment, time, etc. But that doesn't mean they produce flawless beer. Likewise, despite homebrewing being an "amateur" designation, many craft brewers had their start as homebrewers and haven't necessarily attended professional brewing school.
But to say a homebrewed beer can't stand up to a commercial beer is foolish and ignorant. Either you've just never tasted a homebrew that good, or you don't really know as much as you think you do.