ip:     192.168.1.1 /24
/24 means the subnet mask is 255.255.255.0
the 24 represents the number of bits in the network id:
255.255.255.0 in binary is 11111111.11111111.11111111.00000000
                          [       network id       ] [host id]

that's 24 ones, the address is 4 octets each separated by '.'
an octet is a grouping of 8 bits (each digit in binary is a bit)
each binary 1 or 0 represents the numbers below, I'll map out a /24

128  64  32  16  8  4  2  1  .  128  64  32  16  8  4  2  1  .  128  64  32  16  8  4  2  1  .  128  64  32  16  8  4  2  1
___________________________________________________________________________________________________________________________
1    1   1   1   1  1  1  1  .  1    1   1   1   1  1  1  1  .  1    1   1   1   1  1  1  1  .  0    0   0   0   0  0  0  0


if you add up the numbers you get
if we have a 0 then you dont add the number
128+64+32+16+8+4+2+1 = 255 (1st octet)
128+64+32+16+8+4+2+1 = 255 (2nd octet)
128+64+32+16+8+4+2+1 = 255 (3rd octet)
0+0+0+0+0+0+0+0      = 0   (4th octet)
That's how we arrive at 255.255.255.0



Back to what a subnet mask is
The point of a subnet mask to identify what network an address is in.

router1 (address: 192.168.1.1 /24) receives a packet from host A (address: 192.168.1.2 /24)
router1 knows it's network has /24 aka 255.255.255.0 subnet mask, that means the first 24 bits of host A need to match the first 24 bits of his own address. If it doesn't it means host a is not in router1's network.

If we convert router1 and host A's ip address to binary we can check if the first 24 bits match
router1, 192.168.1.1
           192              .              168              .                 1             .                1

128  64  32  16  8  4  2  1  .  128  64  32  16  8  4  2  1  .  128  64  32  16  8  4  2  1  .  128  64  32  16  8  4  2  1
___________________________________________________________________________________________________________________________
1    1   0   0   0  0  0  0  .  1    0   1   0   1  0  0  0  .  0    0   0   0   0  0  0  1  .  0    0   0   0   0  0  0  1

11000000.10101000.00000001.00000001 (router1 ip address in binary)


______________________________________________________________________________________________________________________________

host A, 192.168.1.2
           192              .              168              .                 1             .                1

128  64  32  16  8  4  2  1  .  128  64  32  16  8  4  2  1  .  128  64  32  16  8  4  2  1  .  128  64  32  16  8  4  2  1
___________________________________________________________________________________________________________________________
1    1   0   0   0  0  0  0  .  1    0   1   0   1  0  0  0  .  0    0   0   0   0  0  0  1  .  0    0   0   0   0  0  1  0

11000000.10101000.00000001.00000010 (host A ip address in binary)


the first 24 bits match
11000000.10101000.00000001|00000001 (router1 ip address in binary)
11000000.10101000.00000001|00000010 (host A ip address in binary)


router1 is in the same network as host A