You filter a list to one region and glance at the total. It is wrong: it still includes the rows you filtered out. SUM adds every cell in the range, visible or not.
SUBTOTAL was built for this. Its first argument is a function number that says what to calculate, and the second is the range:
=SUBTOTAL(109, B2:B10)
109 means SUM, ignoring rows hidden by a filter and rows you hid by hand. The matching numbers for the other calculations are 101 for AVERAGE, 102 for COUNT, 103 for COUNTA, 104 for MAX and 105 for MIN.
The shorter set, 1 to 11, behaves the same for filtered rows but still includes rows you hid manually with Hide. In most work you want the 100-series. SUBTOTAL also skips any other SUBTOTAL formulas inside its range, so a total of subtotals does not count anything twice.
AGGREGATE is the more flexible cousin. With function 9 (sum) and option 5, it ignores hidden rows: =AGGREGATE(9, 5, B2:B10). Option 6 ignores errors, and option 7 ignores both, which makes AGGREGATE useful on data that contains #N/A.
You rarely need to type SUBTOTAL yourself. On the ribbon, put the cursor under a filtered column and choose Formulas > AutoSum (or Home > AutoSum). Excel inserts SUBTOTAL(109,...). In an Excel table, turn on Table Design > Total Row and it uses the same function.
The practice grid on this page has no hidden rows, so it checks that you used SUBTOTAL. Try it in a real workbook with a filter on to see the difference. The Analysis track covers SUBTOTAL and AGGREGATE together.