My answer for this Type What You Hear exercise -- Včera jsme na zahradě nebyly -- was considered wrong ("nebyli" was underlined in the correct answer offered.) Since I don't think anything is wrong with my version, I was going to report it... but there's no button for "My answer should be accepted."
As with prepositions in English there does not seem to be any rhyme or reason. In case of a garden you can use both. V would be likelier if the garden was huge like a one attached to a castle. NA is more of your family backyard type of a situation. But as most, this is regional.
There are other situations where both can be used but the meaning is different. NA ulici is on the street. While V ulici is In the street. Similar to English. You play ON the street but you live IN the street.