Use the same ownership period and annual distance for both cars. Compare cash actually paid, not just fuel versus electricity.
For an EV, add home-charger installation or sanctioned-load upgrades. For a petrol car, use realistic city/highway fuel efficiency from your use case rather than a brochure number. For both, model insurance renewal and finance on like-for-like assumptions.