Hello and welcome to healthcare forum.
is a healthy practice and it has no harm to body, sexual life or fertility
. Movement of penis that occurs in vagina during sex, same movement occurs in fist during masturbation.
The complain of night erection you mentioned is neither occurs due to masturbation nor to be considered as a problem, so dont worry.
Best wishes for your health.