According to Islamic law, burying more than one person in the same grave is generally makruh (discouraged) unless there is a necessity or emergency, such as natural disasters or wars. In these cases, it becomes permissible, following the example set during the Battle of Uhud where the Prophet Muhammad (s.a.s) allowed multiple martyrs to be buried in the same grave due to space limitations.
If multiple individuals are buried together, Islamic scholars recommend separating their bodies with earth or other barriers to maintain respect and distinction.