The default place of prayer for Catholic liturgy is inside a church. This has been the case ever since Christianity emerged from the catacombs and was no longer persecuted by the Roman Empire.
The Catechism of the Catholic Church explains this foundational principle in its section on prayer:
The church, the house of God, is the proper place for the liturgical prayer of the parish community. It is also the privileged place for adoration of the real presence of Christ in the Blessed Sacrament.
CCC 2691
The Code of Canon Law similarly states this requirement in regards to the celebration of Mass:
The Eucharistic celebration is to be carried out in a sacred place unless in a particular case necessity requires otherwise; in such a case the celebration must be done in a decent place.
Can. 932 §1.
There are exceptions to this rule, as the Code of Canon Law states above.
If Mass (or any liturgical act) can not be said in a “sacred place,” then it should be done in a “decent place.”
For example, if a priest is hiking in the wilderness, he can celebrate Mass outside, but should make every effort to find a place that is most appropriate for it.
If the priest walks by a church in his travels, it would be more appropriate to celebrate Mass there.
Whenever possible, official liturgical prayer should be done inside a church, but if that is not possible, whatever is most fitting in a particular situation will suffice.