From Manners and Customs of the Bible:

There were several places within the Temple area where doctors of the law met their disciples. One of these places was in the cloisters described in the note on Matthew 24:11And Jesus went out, and departed from the temple: and his disciples came to him for to show him the buildings of the temple. (Matthew 24:1) (#704). Another was in the synagogue which was in the Temple enclosure. After service the doctors admitted any who wished to converse with them on matters pertaining to the law. There were also other places resorted to for a similar purpose; and Lightfoot declares that it was not impossible for Jesus to have been in the great Sanhedrim itself.
There is no reason to suppose that in the conversation which Jesus held with these learned men there was anything like controversy. He simply followed the custom of the time, which allowed anyone who chose to question the doctors on any points on which they desired information.