A good way to describe it is a dumb printer. It exists to print a proper ballot for the elector who then drops it off. The machine _just so happens_ to also have a secondary counter while it prints, so it can be secondary verified for extra safety. The paper is what matters and it's still there. This is called VVPAT, Voter Verified Paper Audit Trail [1]. It has been proven over and over to give consistent recounts and restore trust in elections.
Over the course of time, after many many recounts, it becomes obvious that the machine-printed ballot and machine do not ever diverge. So it _just so happens_ that for convenience, the machine has grown to get counted first. If anyone has a doubt, they can easily go back and count the ballots which are stored forever.
Trivia: First time a Cabinet-rank senator in India lost election by 1 vote [2]. Recounts tallied down to the dot. It since happened again. Chaos still did not break out. Candidates were not fighting over who was the winner. Reason? Voting machines and verified ballots. Recounts won't change reality.
Answer to the primary OP's question: "Why not open source the software" – is the crux of the Voting machine is mainly 1950s pseudo-mechanical hardware. They are not networked. This is technology older than floppy disks. A lot of in this forum imagining "software" think in terms of C or Python, because that's the target audience here. Yo, it's not. It's not running an x86 processor.
It does not have a turing complete language to open source. If you want it, get a thrown away one. But open sourcing the "software" (if you call a few registers and a counter that) – doesn't make any sense as it doesn't give any picture.
Second – to a lot of commenters, why these machines? Single answer: Consistent recounts. With paper, it's 100% guaranteed that "No two recounts will ever be the same". It's a human process. Two humans verifying it will never come to the same conclusion. One will say the "ballot stamp was not in the right place", another will say "chad did not fall off the paper", someone else might just be tired in the night, so on and on. As a democratic society, we have had large cases of recounts that it's not even a surprise anymore. It has become the go to whining and agitation tool for every single loser of every close election. For the continued functioning of democracy, we have to put an end to this recount problem.
It's a pity that in the US where you had two really high profile elections (2000 and 2020), and you still cannot figure out how many times to recount to believe the result. Best of 3 recounts? Best of 5? Does that even improve trust?
I'll finally leave you with the summary of an excellent video on elections in India before/after voting machines. "Don't shoot the messenger" [3]. Every loser will complain and blame something. Hacking the voting process, obstructionism, who's issued voter IDs, where and how many voting centers are placed, gerrymeandering, media, pre-mature leading polls, on and on and on. All this thing about Voting machines is a classic case of shooting the messenger. The voting machine only exists to give one less reason to blame on. Don't shoot the messenger.
1: https://en.wikipedia.org/wiki/Voter-verified_paper_audit_tra...