In most cases "im Garten" is used for being in the garden, although with other nouns, e.g. Berg, that could only mean to be into or within the thing itself. But sometimes one sees "auf dem Garten". Most often it is with the verb liegen, which explains the use of auf. But here is an example taken from DWDS for which I cannot explain the use of auf instead of in:
Im Garten wurde auch zu Mittag gegessen.
Sonntag soll ich auf dem Garten zu Mittag essen, aber ich will nicht.
What is the explanation? Is it simply that both prepositions are accepted in this context? If so, what makes Garten different than other nouns in this respect, like Feld or Berg? It would seem that auf dem Garten would actually be the choice that was more consistent with the use of these prepositions elsewhere.