Like Jorge Castro says here, we usually don't know for sure.
Investigating bugs is what we're poorly equipped to do here. So, if the problem has to be investigated as a bug, it can usually be considered a bug.
Occasionally a program crashes for some reason other than a bug. But usually, a program crash has to be investigated as a bug--for example, producing and inspecting a stack trace--to figure this out.
Kernel panics can be caused by hardware problems, but even then it's hard to investigate them without the same mindset and techniques used to investigate a kernel bug. Especially if they are introduced by upgrading to a new kernel, or a new Ubuntu release, kernel panics are usually closed as bugs.
Sometimes the OP knows it's a bug. (That doesn't mean they're deliberately misusing the site.) Questions that say things like "can someone fix this bug please?" should almost always be closed as bugs.
Of course, there's no bright dividing line between investigating bugs and investigating configuration problems and the like, either. So outside those three cases, typically it's best to explain in a comment why you think it's a bug. Sometimes questions are wrongly closed. When they are, they can be reopened.