The Quran says, 'do not kill yourselves, for Allah is Merciful to you'. The Prophet Muhammad ﷺ warned that whoever kills himself with a piece of iron will be tormented with it in the Fire, and he told of a man in an earlier nation who was wounded, could not bear the pain, cut his hand and bled to death. Allah said, 'My servant hastened his own end, so I have forbidden him Paradise.' Pain and despair are real, and Islam answers them with patience, treatment and hope in Allah's mercy. Scholars add that the final judgment on anyone who died this way belongs to Allah, who knows his illness and suffering.
The second wrong is the killing of others. The Quran teaches that killing a person unjustly is like killing all of humanity, and the Prophet ﷺ forbade the killing of women and children even in war. An attack on a market, a train or a place of worship is therefore murder in Islamic law, whatever slogans the attacker uses. When Muslims speak of a martyr (shahid), they mean someone killed while defending others in a lawful fight or in some other way recognised in the texts, not someone who takes his own life in order to kill civilians.
To be fair to the history of the debate: a small number of contemporary scholars argued that a self-sacrificing attack on soldiers could be allowed in a land under military occupation. Those opinions were widely criticised by other scholars, and the overwhelming majority of scholars and fatwa councils reject the practice altogether, above all when civilians are targeted. Muslims have themselves been among the victims in mosques and markets.