The ideal length of a cat scratching post or scratcher has mostly to do with how long your cat is and the angle from which it's used. It should be tall enough or long enough for your cat to get a full stretch of the body.
A vertical scratcher (e.g., freestanding scratching post) should ideally accommodate the full length of your cat (from standing on back paws to outstretched front paws)
A horizontal scratcher (e.g., scratching pad that your cat can stand on) can be shorter because of the different scratching angle (a full stretch of your cat's back should be possible).
Additionally, some scratchers allow your cat to sit or stand on the floor farther away from the scratcher which can compensate for the shorter length of the scratcher.
Kittens and smaller cats can make do with a smaller scratcher while a larger cat requires a taller or longer scratcher to get a full stretch. Just keep in mind that kittens get bigger and may outgrow the scratching post if it's not big enough.
22-inch scratching post for kittens and smaller cats
Scratching posts advertised for kittens can be around 20"
32-inch SmartCat Ultimate Scratching Post
Scratching posts for adult cats are around 30".