А так было бы еще проще
<!doctype html>
<html lang="ru">
<head>
<meta charset="utf-8">
<title>index</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="description" content="index">
<meta name="Keywords" content="index">
<style>
.blok{
width: 400px;
height: 100px;
margin: 10px auto;
display: flex;
justify-content: space-around;
}
.kvadrat{
width: 100px;
height: 100px;
border: 3px solid #000;
}
.kvadrat.aktiv{
border: 3px solid #0504aa;
}
.kvadrat:focus{
outline: none;
}
</style>
</head>
<body>
<div class="blok">
<button class="kvadrat aktiv"></button>
<button class="kvadrat"></button>
<button class="kvadrat"></button>
</div>
<script>
let blok = document.querySelector(".blok");
let aktiv = function ({target}) {
target = target.closest(".kvadrat");
if(!target) return;
this.querySelector(".aktiv").classList.remove("aktiv");
target.classList.add("aktiv")
}
blok.addEventListener("click", aktiv);
</script>
</body>
</html>