You can do this by redefining the accent macros only for mathmode, using the
\everymath token list. You can do this as follows:
Note that this will only be sufficient if you use
amsmath environments, such as
gather, for displayed equations. (You should be doing that anyway, but this does bear noting.) This should also preserve the normal meanings of the accent macros for text mode.
edit: for your revised question, there is no mechanism to define a new macro to accept an argument which immediately precedes it, as in the examples you give.