Yes, the immune system detects a pathogen and sets about dealing with it in a series of reactions. A lot of symptoms to either a natural pathogen, like a virus, or an unnatural one like a vaccine, are the result of the innate immune system doing it's job. But the innate immune system isn't what vaccination is trying to stimulate. Immunity is gained by stimulating the adaptive immune system.
I can't speak with any degree of confidence on why the second jab sometimes might cause a stronger reaction than the first. All I can do is speculate which probably won't help anything.