An antigen is any large molecule or organism which triggers a specific (rather than generalised) immune response against itself within the host body. When the body detects an antigen, the adaptive immune system produces B & T lymphocytes with antigen receptors on their surface of specific shape to bind with, and destroy that antigen; the process takes a few days, but once made, antigen receptors for that pathogen remain in the body ready to mount a much faster attack should the same antigen be encountered in the future.
Some antigens only trigger a response in some people - for instance, pollen causes hayfever (which is an immune response) in some people, but not in others; in autoimmune disorders, the body mistakes normal body cells for antigens, and attacks them in - in multiple sclerosis, myelin is seen as an antigen, and is destroyed.
In vaccinations, dead or weakened antigens are introduced into the body, which then produces lymphocytes to deal with it & any future invasions by that antigen, giving the person immunity.