Can students and people having to leave the US due to visa issues still claim retirement funds?

I was wondering if you knew the answer to this random question: can someone invest in the US market without a social security number ? For example, if a student from a different country wanted to pursue FIRE would they be able to enroll a broker in the US. what would happen at retirement age if their status was to change or get revoked? I think this is something many students or even folks with visas may be experiencing.