Note: it's not only with superhero films but trilogies in general and actor sign contract based on the initial plannings.
Because of Rule of three
The Latin phrase "omne trium perfectum" (everything that comes in threes is perfect, or, every set of three is complete) conveys the same idea as the rule of three.
Three is magic number to convey a story or even a scene. It's quite common trope in literature too to start with trilogy but lately they get expended later on with prequels and sequels.
And making it in three parts can also act as extended Three-act structure
Take Dark Knight trilogy as an example:
Batman Begins can act as Act 1: Setup; we introduced with main protagonist and see his origin and reasoning for what he do.
The Dark Knight can act as Act 2: Confrontation; here stakes get higher and hero get confrontation with bigger problem. He got retired and kind of broken.
The Dark Knight Rises can act as Act 3: Resolution; we got resolution of the story which started with first film and hero's name get cleared and he died as martyr (or not died).
Spider-Man can't fall into that structure as it was never suppose to stop at three but it can be applied to many 3 part films.