When a person gets infected for the first time of COVID-19, several days have to pass until their body realises that it has the disease, and uses whatever is necessary to eliminate and protect that threat.
COVID-19 vaccine develops immunity without having to catch the sickness, preparing the cells to fight against the infection. Generally, after the shot, it takes some weeks to produce what it needs to be completely immune. This can make a treated person to get sick just before or after the vaccine is injected. It occurs, mainly, due to the lack of time that the body has had to produce the resistance it needs. It may happen that someone can show similar symptoms after being vaccinated. This is normal and it is a good sign. It means that your body is learning to fight the disease and, in its process, creating immunity to that virus.
Experts are still studying for how long the protection will last, since it is such a new investigation, they do not have any solid results. Nevertheless, some are starting to sat that it might be recurrent vaccination, such as the common flu one.