It varies. The first time you are exposed to a foreign protein you will have no reaction. You have no antibodies. If your T-cells (think of them as the security guards) label that protein as harmful, they crank up the antibody factory, with a reverse template of the foreign protein.
If the protein isn’t very different, antibody production is slow. If its very different all the stops are out and the antibodies come off the line ready for battle.
So let’s say the foreign protein is pennicillin.
Your T-cells say, who goes there? and pennicillin doesn’t answer.
Antibody templates might take a few days. By the time they’re ready to make the finished product (antibodies) you’ve finished your course of treatment. T-cell security says stand down, but save that template, and antibodies.
Well, antibodies have a shelf life. Depending on the foreign protein, they may last decades, but over time the number decreases.
So, a year later, you get another infection and again get pennicillin. T-cells drag out the template, and any antibodies still lying around. If there are enough, you may get a rash, and the factory has the means, and is making more. But once again you finish the course.
Since it took less time to make the new antibodies, you now have more lying around.
So, another infection comes along, and you forgot to tell you doctor you got itchy on the last day of the pennicillin.
First dose, we have LOTS of antibodies ready to go. With in minutes, you have a rash, then trouble breathing. 911. Bad day.
Some antibodies are lazy, like the ones for tree pollen. They usually just effect where the pollen touch mucus membranes.
But, anything you take inside (swallow or inject) has a potential to cause the factory to pay over time. Bad day. 911.
Some are so bad that just touching the offending protein can cause anaphylaxis. peanut allergies are an example.
I have an allergy to an injectible antibiotic I’ve never been treated with. I only have to get it on my skin to have an immediate reaction.
So the answer to your question is, it varies.