Attacking electricity power installations is not NECESSARILY considered to be a war crime. This Reuters article is a good introduction to this issue.
https://www.reuters.com/world/europe/when-are-attacks-civilian-infrastructure-war-crimes-2022-12-16/
Consider this from the USA Law Of Armed Conflict (LOAC) Manual:
"Electric power stations are generally recognized to be of sufficient importance to a State’s capacity to meet its wartime needs of communication, transport, and industry so as usually to qualify as military objectives during armed conflicts.”
“Military objectives, insofar as objects are concerned, include ‘any object which by its nature, location, purpose or use makes an effective contribution to military action and whose total or partial destruction, capture or neutralization, in the circumstances ruling at the time, offers a definite military advantage.'”
In 2020, the RAND Corporation asserted:
“The U.S. Department of Defense (DoD) increasingly relies on electric power to accomplish critical missions. As a result, ensuring that forces and facilities have access to a reliable supply of electric power is critical for mission assurance. However, DoD does not directly manage its supply of power; most of the electricity consumed by military installations in the continental United States comes from the commercial grid—a system that is largely outside of DoD control and increasingly vulnerable to both natural hazards and deliberate attacks.”
So, if one of the biggest and most technologically advanced militaries in the world requires access to civilian electricity installations.....so do many other militaries.
Including terrorist groups such as Hamas who control territory with a defined border.
Attacks on electricity installations have to have a clear military advantage.