x = np.array([[1.0, 2.0],
[3.0, 5.0]])
print(x - x.max(axis=-1))
print(x - x.max(axis=-1, keepdims=True))
[[-1. -3.]
[ 1. 0.]]
[[-1. 0.]
[-2. 0.]]
The second answer is right: each row minus its own max, so each row's largest entry becomes 0. The first is wrong, and nothing errors.
Without keepdims the maxes come back as a flat (2,) array. Broadcasting lines a flat array up with the columns, so column j loses row j's max. On a square matrix the shapes fit, and the result is quietly wrong.
keepdims=True keeps the reduced axis with size 1, so the maxes stand in a column, one per row. Then the subtraction, and the division by the sum, broadcast back along the right axis. The idea is the point, not the name: np.expand_dims(x.max(axis=axis), axis) puts the axis back by hand and does the same job.
Scores going into a softmax are often called logits. The practice tests feed logits around 10,000. The plain formula fails them, and the shifted one passes.
In the editor, write the stable softmax(x, axis=-1). The checks feed it logits around 10,000, a batch of rows, and axis=0.