In a mathematics publication, is it preferable to state all definitions immediately, or as they arise?
There is no general rule. Different authors have different opinions about this. To my knowledge no mathematics journal has guidelines about this sort of thing.

A rule of thumb could be that if your notation is going to be used throughout the paper, then it should be introduced at the beginning in a special section called "notations", "conventions", "background", or however you want to say this. If the notation is only going to be used locally in some section or even one proof, then I would introduce it at that point.

Another possibility is to make a categorized table of notations at the beginning or an alphabetical list of notation with references to where the object is defined, if your paper is long and complex enough to justify it. This can of course be combined with the previous rule of thumb.

I would recommend against making the "background" section as part of the introduction. The introduction is supposed to be something that can be read by almost everyone slightly interested in the paper, to know what the main results are and how they fit with the general literature, and in case of stars aligning, whether the paper is worth reading. (The abstract is to decide whether you'll even glance at the paper at all.) Keep it short and simple and avoid introducing too many things at once. In my opinion it is a mistake made by many younger, and also more experienced authors to make the introduction way too technical.