Is it a good idea to write one's own recommendation letter for a postdoc application?
In the U.S., in mathematics, this might be a bad idea. The "voice" of letters of recommendation surely needs to be that of a relatively senior person, writing to the relatively senior people who will be reading the letters.

While it may be true in principle, or approximately, that one knows one's own best features better than anyone else, in practice this is often not quite the case. That is, more senior people may value, and observe, longer-term virtues that are not well understood by a very junior person. At the same time, things highly valued by a novice may be viewed as transient by a more senior person.

(Of course, there is nothing that prevents more senior people from being immature and "clueless", etc., and that leads to unhelpful letters, obviously.)