If involuntarily someone ejaculates without any touching but after having some natural sexual excitement, will it be considered masturbation and is it a sin?

No if it’s involuntary it is not a sin, however the person needs to do ghusl