This reminded me of neonatal lupus. Lupus is an autoimmune disease where your own antibodies attacks your tissues. In neonatal lupus, the newborn is born with lupus ... because materal autoimmune antibodies are able to cross the placental barrier. So the newborn 'inherits' a lupus condition, which usually self resolves within a month once the maternal antibodies have disappeared.
https://rarediseases.org/rare-diseases/neonatal-lupus/
This is presumably applicable to other maternal antibodies, which may give immunity against germs the infant has never been exposed to. However, this is a 'temporary' immunity, and distinct from the adaptive immune responses associated with 'immune system memory'.