$(document).ready(function () {
let $flatHead = $('[data-class=flat-head]');
let $openedBody = null;
$flatHead.click(function () {
if ($openedBody) {
$openedBody.removeClass('d-block');
}
$openedBody = $(this).siblings('[data-class=flat-body]');
$openedBody.addClass('d-block');
});
});
UPD: добавил $flatBody.hide(); вроде, то, что надо