If you want to detect equivalence of sizes and shape, torch.equal is the right thing to use.
In your example above, a == b, we are broadcasting a and b and then performing the operation: https://pytorch.org/docs/stable/notes/broadcasting.html.
The steps look roughly like the following:

a has size [1, 1], b has size []
If the sizes are broadcastable (they are), we make it so that they have the same size before evaluation. So a_broadcasted has size [1, 1], b_broadcasted has size [1, 1]
We compare a_broadcasted with b_broadcasted. This produces a tensor with size [1, 1] that has one element True.