When I attended mass for a priest celebrating 40 years of the priesthood, he was the celebrant. However, the bishop was there but sitting to the side in a choir dress and a stole. Why is this so?
A Bishop can never be a concelebrant if the main celebrant is a priest. Even if the Bishop is not the main celebrant, he must still preside and thus say all the presidential prayers and the final blessing.
Obviously in the Mass you describe its more appropriate for the priest celebrating his 40th anniversary to be the main celebrant. In such situations the bishop will simply attend in choir dress.
No. 18 of the Ceremonial of Bishops:
Any community of the altar, under the sacred ministry of the bishop, stands out clearly as a symbol of that charity and unity of the Mystical Body without which there can be no salvation.
Thus it is very fitting that when the bishop, who is marked by the fullness of the sacrament of orders, is present at a liturgical celebration in which a congregation takes part, he personally preside. The reason for this is not to give added outward solemnity to the rite, but to make the celebration a more striking sign of the mystery of the Church.
For the same reason it is fitting that the bishop associate presbyters with himself as concelebrants.
When a bishop presides at the Eucharist but is not the celebrant he does everything in the liturgy of the word that belongs to the celebrant and he concludes the Mass with the rite of dismissal.
This exact question was asked of the Congregation for Divine Worship and the Sacraments and the answer was published in 2009 in Notitiae. The question was “Whether it is licit for a bishop to concelebrate on occasion of a priestly jubilee in which he takes a place among the priests ceding the role of principal celebrant to the priest celebrating his jubilee?” The Vatican congregation replied, “Negative.”