The Covid vaccines are tested the same way lots of other medicines and drugs are tested. This includes trials where people volunteer to be injected.
People in the trial are checked and tested a lot and the vaccine is only allowed to be used when it is completely safe.
Usually it takes a few years to test a new medicine. But because it is an emergency the tests and checks were done quickly. The tests were the same, just quicker, because lots of people worked really hard on it.