If you would ask this question about 20 years ago I would give you a different answer than now.
20 years ago there were many unreliable casinos on the internet because there was no good license system and organisation to check. So there were many online casinos who were taking deposits from players and suddenly they disappeared.
Since 2015 everyhting becamse much safer with a good license systems in different countries and professional companies who are launching online casinos. Of course there are still casinos which are a bit difficult to trust but the chances are much lower than before.
Do I have to register to play at an online casino?
You can always play in fun mode without opening an account. But if you want to play for real money than you need to open an account, unless you choose for a Pay & Play Casino.
Online casinos need to know from who they receive the deposits and to who to payout if you win at the casino. When you deposit more than a certain amount or when you win money and request a withdrawal the casino wants to receive documents (ID, Utility Bill, etc.) from you. They want to compare your account details with the documents you send. That's why its very important to use the correct details when you open a new account because a casino might decide not to pay you if the details are not correct.