Work through “Hi”: the bytes are 72 and 105 — binary 01001000 01101001. Regrouped into 6-bit chunks: 010010 000101 1001 — that is 18, 5 and 36, which the alphabet maps to S, G and k. The input was one byte short of a full group, so one = pads the end: SGk=.
Decoding reverses the lookup. Any character outside the alphabet, padding in the wrong place, or a length that is not a multiple of 4 means the input is not valid Base64 — this converter tells you the exact position instead of failing silently.