**Yes**, if you saw a copy of an exam that was not released, you could be in trouble, and it is a form of cheating. 

If it was released to the class, then there is no issue.

How likely the professor is to accept your explanation you thought it was OK to look at depends on a number of factors. Does their syllabus say whether they release their tests? Have previous tests in this class been released publicly?