When people talk about encryption keys, they are usually thinking about a type of encryption called a "block cipher", meaning that it iterates over the plaintext message one "block" at a time using the key and the output of the previous block to produce one block of cipher text. The block size (number of bits in a block) is usually fundamental to how the algorithm is designed and can not be changed on the fly. There are lots of different kinds of block ciphers, so it's hard to generalize.
The key size is often the same as the block size. Most modern block ciphers also allow a key that's larger than the block size though the sizes are usually related; key size needs to be a multiple of the block size, or they both need to be a multiple of 32, or something like that depending on the algorithm.
Let's dive into a concrete example:
AES-256. Wikipedia says:
For AES, NIST selected three members of the Rijndael family, each with a block size of 128 bits, but three different key lengths: 128, 192 and 256 bits.
AES is a subset of a more general family of ciphers called Rijndael ciphers. This quote (also from wikipedia) gives us a bit more context:
AES has a fixed block size of 128 bits and a key size of 128, 192, or 256 bits, whereas Rijndael can be specified with block and key sizes in any multiple of 32 bits, with a minimum of 128 bits. The blocksize has a maximum of 256 bits, but the keysize has no theoretical maximum. AES operates on a 4×4 column-major order matrix of bytes, termed the state (versions of Rijndael with a larger block size have additional columns in the state).
You can see that 4x4 bytes (=128 bits) is the fundamental block size of AES. While the number of bits in the key does not need to be the same as the block, it does need to a multiple of 32 in order for the math to work out properly.
As for hashes: if you dig into hashes, you'll learn that most of them work in the same way: they have a fundamental block size which is also usually a multiple of 32!