I'm assuming from my experience with Canadian academia that this is a test that is taken in class, you turn it in at the end of the period, and then your professor either gives them back, graded, or allows you to come to their office and see your graded test.

Yes, if you saw a copy of an exam that was not released after the exam, it could be considered a form a cheating and you might be in trouble.

If it was released to the class (or is a take home exam everyone had a chance to see), 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?