European Commission bug bounties for Free (Libre) and open source Software
ec.europa.eu
ec.europa.eu
In particular, something like a self-hostable secure messenger has important cybersecurity implications, so it makes sense that governments (and supranational bodies) would devote funds towards protecting citizens that way. For other pieces of software there may be less of a justification, but governments do sometimes (economically rationally) invest in supporting industries so that they grow and create jobs.