There are several possibilities. One is the presence of methanogens, which are microbes that produce methane. It’s also possible that carbon-rich meteorites strike Mars’s atmosphere like an organic bomb and release methane when the Sun’s ultraviolet radiation heats the carbon to extreme temperatures.
There are many more theories as well.The second mystery is why Mars’s methane keeps disappearing.
It’s believed to be stable for about 300 years in the atmosphere. So that raised the question of whether we had actually detected the gas at all. But some of the occasional spikes were undeniable. So maybe winds are blowing the methane beyond Curiosity’s range of detection, although that doesn’t explain certain findings by orbiting spacecraft.