The ideal length of a cat scratching post or scratcher has mostly to do with how long your cat is. 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) needs to accommodate nearly the full length of your cat (from back paws to outstretched front paws) while a horizontal scratcher (e.g., scratching pad that your cat stands on) can be shorter because of the different scratching angle (accommodating your cat's back and outstretched front paws).
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.
What sizes do scratching posts come in?
Kittens and smaller cats can make do with a smaller scratcher while a larger cat requires a taller or longer scratcher to get full stretch.
The scratching posts advertised for kittens can be around 20" while the ones for large cats can go up to around 40".
The taller the scratching post is the heavier and/or the wider the base needs to be to keep the post from wobbling too much or even tipping over when your cat uses it.