Our Gemara on Amud Beis tells us:
Rabbi Meir said: One who finds another in mourning after twelve months and speaks to him words of consolation, to what may this situation be likened? To a person who broke his leg and it healed, and afterward a physician found him and said to him: Come to me, for I will break it a second time and then I will heal it, so that you may know how good my medicines are and how well they work. And it is similarly codified in Shulkhan Arukh YD 385:2.
The idea being expressed by the Gemara is, that the person is so in love with his own ability to comfort that he does not care about the actual mourner’s needs.It is Like a physician who breaks another person’s leg in order to show how competent he is at healing it.
Which brings me to the question of why do people say the stupidest things at Shiva? People suggest doctors and hospitals that cured their uncle, even though clearly the niftar is no longer alive and beyond cures. People come at crazy hours in order to fulfill “their” mitzvah. People tell mourners how they should feel: “ You should feel happy, at least he didn’t suffer.“ You should feel happy, at least he didn’t live like a vegetable for five years like my aunt Henya.” “ you should feel terribly sad at the loss of such a great and wonderful Tzaddik that he/she was (Meanwhile he was a child abuser)”. And of course, last but not least, they decide how long the person should have lived. “she lived until she was 90, she had a full life. You should be grateful.” Yes, that makes a lot of sense. Most people who are 90 and healthy say to themselves, “ I have lived long enough. I’m perfectly fine With suddenly dropping dead of a heart attack right now.“
That is why the teachings of our sages are helpful for setting good boundaries in the Shivah house. The Gemara later (27b) tells us one should not speak in front of the mourners until they speak first. This is a halakhic rule but it also touches on a deeper theme, which is to let the mourner’s mood and feelings lead, and not your own fears, anxieties and projections. People say foolish things at a Shivah house because of their own fears and impotence in the face of death.