But then why does it say “whoever believes in me”?
I can only give you how I understand the verses - there is no official interpretation.
I would still understand the “whoever” as applying to the apostles – like “whoever of you”. Jesus is in a room, talking to the 11 remaining apostles. He is saying it to them – “Amen, amen, I say to you, whoever…”
It’s hard to conceive of any physical miracles that would be “greater” than those Our Lord performed (healing, raising from the dead, multiplication of loaves, …), and for that reason I see it as a reference to the sacraments. It is the spiritual healings and provision of supernatural nourishment (sanctifying grace) in the sacraments that surpass physical miracles. In connection with that, I guess one does have to remember that in an emergency, lay people can baptize. And, in the Sacrament of Matrimony, it is the man and woman who perform the sacrament.
Added note: I just checked the Greek, and I couldn’t find a word for “whoever”. But, I am not knowledgeable in Greek, so perhaps someone who is can do some checking on that and let us know.
For example, the Douay translates the verb “believe” in John 14:12 with the pronoun “he”, and not “whoever”.
Otherwise believe for the works themselves. Amen, amen, I say to you, he that believeth in me, the works that I do, he shall do also, and greater than these shall he do: because I go to the Father.