It actually works by infecting some of your cells, much in the same way a virus would, and forcing/tricking those cells to produce proteins that should incite an immune response. The big difference between the COVID vaccine and a real virus is that it does not contain enough genetic information to replicate beyond the first cellular infection. It's not self replicating (although in viruses the term self replicating is a misnomer, because they trick your cells into doing the replicating).