Почему вы хотите применить границу в таблице, вы можете сделать одну вещь. Вы примените границу к родительскому элементу таблицы, так как в вашем случае это элемент DIV.
HTML Элемент таблицы имеет рамку по умолчанию -spacing: 2px, поэтому вам также нужно изменить его на 0px.
Вот код для вашей справки
<div style="border:1px solid #e8e8e8; height:500px; margin-top:2rem; margin-bottom:2rem; overflow-x:scroll; overflow-y:scroll;">
<table style="border-spacing: 0px; font-size:1rem; margin:0; padding:0; table-layout:fixed; width:100%;">
<thead>
<tr>
<th style="background:#f9f9f9; color:#000; font-weight:bold; position:sticky; top:0; width:150px;">
a
</th>
<th style="background:#f9f9f9; color:#000; font-weight:bold; position:sticky; top:0; width:150px;">
b
</th>
<th style="background:#f9f9f9; color:#000; font-weight:bold; position:sticky; top:0; width:150px;">
c
</th>
<th style="background:#f9f9f9; color:#000; font-weight:bold; position:sticky; top:0; width:150px;">
d
</th>
<th style="background:#f9f9f9; color:#000; font-weight:bold; position:sticky; top:0; width:150px;">
e
</th>
<th style="background:#f9f9f9; color:#000; font-weight:bold; position:sticky; top:0; width:150px;">
f
</th>
<th style="background:#f9f9f9; color:#000; font-weight:bold; position:sticky; top:0; width:150px;">
g
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="background-color:#e8e8e8; height:1000px">1</td>
<td style="height:1000px">2</td>
<td style="background-color:#e8e8e8; height:1000px">3</td>
<td style="height:1000px">4</td>
<td style="background-color:#e8e8e8; height:1000px">5</td>
<td style="height:1000px">6</td>
<td style="background-color:#e8e8e8; height:1000px">7</td>
</tr>
</tbody>
</table>
</div>