The vaccine enables the body to build immune defence specifically targeted at the virus. As soon as the body has been exposed to the virus, it has the immune defence to fight it. Vaccination therefore boosts and teaches our immune systems specifically how to fight COVID-19.
For your booster, you should ideally have a variant-adapted (bivalent) mRNA vaccine or the protein vaccine from Novavax if these are available (see further below for exceptions for certain groups). The type of vaccine you had in the past has no impact on the choice of vaccine you receive for your booster.