I heard a priest say that the Church can change and has changed the number of the sacraments. He said that there was a time when there were more than the seven we know today. Is this true?
Yes and no. It depends on how you use the term sacraments.
The Councils of Lyons (1274) and Florence (1438-1445) taught there are only seven sacraments, the ones we know today. The Council of Trent reiterated this teaching in response to Protestant rejection of some of the sacraments.
So for the last seven centuries or so we’ve been used to saying there are exactly seven sacraments.
But the concept of a sacrament was insufficiently developed in the ancient Church, and there was dispute about which Christian rituals and practices should be called sacraments. Sometimes the term was used by the Fathers to embrace practices we would deem sacramentals today. Sometimes its use was wider still, so that anything which could have a religious symbolism was called a sacrament.
Why this multiplicity of definitions? Because agreement hadn’t been reached on what the word sacraments should mean. As a result, many things were called sacraments in the early Church which subsequently were not identified as such.
Nowadays we again see some of the ancient usage. Some theologians use the term in a wide sense. Of course, this can be confusing.
The thing to watch out for is a lack of distinction: A few writers put the seven traditional sacraments on a par with mere sacramentals or with mere “signs,” and the adjective “mere” fuzzes the picture as it gets applied also to the seven.