Short Answer
See Why do some bad traits evolve, and good ones don't?
Evolution of venom is complicated and full of convergent events.
Our awareness and perception of venom production is biased toward recognition of chemicals as human-impacting venoms, and the full scope of venom production and their various ecologies have not holistically or thoroughly been studied.
Venom vs poison: both are toxic but their delivery sytstem differs: "poison" is ingested/inhaled/absorbed and "venom" is injected [by teeth, sting, spine, claws].
Long answer
I definitely want to point you toward one of our most linked posts on this website, Why do some bad traits evolve, and good ones don't?, as it mostly answer your otherwise nearly impossible-to-accurately-answer question. However, I'm going to provide a bit more nuance by pseudo-answering your questions with some comparisons between two of the groups you asked about (reptiles vs mammals) and a number of citations to try to demonstrate how "messy" (complicated) this answer might be to answer.
You're correct that a number of reptiles are venomous -- about 1/5 of snakes for example. According to National Geographic approximately 600 out of 3,000+ species of snakes are venomous. But it's not just snakes; Gila monsters and other non-snake "squamates" also are known to produce venom. This would suggest that production of venom is possibly a fairly early trait to evolved in squamate evolution. Still, it turns out only a single clade of reptiles is known to commonly produce venom(s).
According to Wikipedia:
Recent research suggests that the evolutionary origin of venom may exist deep in the squamate phylogeny, with 60% of squamates placed in this hypothetical group called Toxicofera. Venom has been known in the clades Caenophidia, Anguimorpha, and Iguania, and has been shown to have evolved a single time along these lineages before the three groups diverged, because all lineages share nine common toxins.[24] The fossil record shows the divergence between anguimorphs, iguanians, and advanced snakes dates back roughly 200 million years ago (Mya) to the Late Triassic/Early Jurassic,[24] but the only good fossil evidence is from the Middle Jurassic.[25]
- Citations: [24]: Fry et al. 2006. "Early evolution of the venom system in lizards and snakes". Nature 439(7076):584–588. doi:10.1038/nature04328. [25]: Hutchinson et al. 2012. "Tikiguania and the antiquity of squamate reptiles (lizards and snakes)". Biology Letters 8(4):665–669. doi:10.1098/rsbl.2011.1216
Fry et al. (2005) shows us this "venom clade" visually in figure 1 of their paper:
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/tC4rHtWym.png)
Figure 1 copied from Fry et al. (2005)
Let's contrast with mammals.
According to Ligabue-Braun (2017):
There are four mammalian orders with known venomous representatives, as recognized today. These comprise solenodons and some species of shrews (Order Eulipotyphla), platypuses (Order Monotremata), vampire bats (Order Chiroptera), and slow lorises (Order Primates)
Fitzpatrick et al. (2022) provide the following to aid in viewing this phylogenetically:
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/9Q5QLZsKm.png)
Figure 1 copied from Fitzpatrick et al. (2022)
This phylogeny suggest less conservation of this venom trait. Knowledge of these species confirms that their venom appears to be unrelated evolutionary. Schendel et al. (2019) writes (my emphasis):
Venoms are one of the most convergent of animal traits known, and encompass a much greater taxonomic and functional diversity than is commonly appreciated.
Venom systems have evolved independently more than 100 times in an extremely wide range of taxa that includes at least eight separate phyla (see Figure 1)
In summary, as seen from Figure 1 below copied from Schendel et al. (2019), what we do know about the evolution and ecology of venom is quite widespread across the animal kingdom and quite messy (complicated) for exploring:
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/GPZrPWaQm.png)
Figure 1 copied from Schendel et al. (2019)
In addition to this point, we actually are still not fully aware of the full scope of the many toxins in the animal kingdom. Schendel et al. (2019) also point out that our perception of venom presence is biased due to a focus on venoms that impact humans vs. a broader ecological context:
Venoms and toxins have thus been primarily characterized using human and other mammalian tissues and receptors. An exception to this is the targeted screening of venoms as sources of novel insecticides [15,16,17,18], which typically rely on a limited number of pest or pest-related insect species. Nevertheless, most toxin pharmacology is based on species that are ecologically irrelevant and/or represent only a fraction of the taxonomic diversity targeted by the venomous animal in nature, which likely affects the perceived ecological role due to differences in toxin activity in the model and the ecologically relevant species