I don't think we can prevent fraud, the best we can do is source voting machines according to a spec from multiple vendors, and source software from multiple vendors as well, and do independent inspections of both by multiple 3rd parties. It would be a significant undertaking to compromise everything.
With a paper vote, you place trust in those who collect, store and, count, and you can always recount if needed. With electronic voting you place that trust in those that produce the hardware and software.