At a basic level, the length of your film should be dictated by the story and how you edit it. Most stories have a natural pace which will suggest an appropriate length, so you should base the final running time on the needs of your story rather than try to adhere to a specific number.
That said, there are a couple of considerations you should bear in mind when writing and editing a film. The first is with regards to short films. Most festivals and other outlets which show shorts these days tend to prefer films which are 10 minutes or less (although up to 15 minutes is normally fine too). Once you start getting a short much beyond 15 minutes it becomes very difficult to program so the number of distribution and exhibition options tends to shrink pretty quickly.
The second is with regards to feature films. Most distributors like features to be between 90 and 120 minutes. The lower end of that scale is best for strong genre films (e.g. horror) , whilst drama can get away with being slightly longer. Much above 120 minutes and the exhibitors (i.e. cinemas) start to grumble because they can’t fit as many screenings into a day, and therefore can’t earn as much money. Films like “Lord of the Rings” can get away with being 3 hours long because they are event films which the audience actively seeks out. Independent films don’t have that luxury.
So from this, you can see that films which are between 15 and 90 minutes are problematic. They exist in a kind of no man’s land between a shorts and features and are therefore very hard to distribute. It’s advisable not to aim to make a film between these lengths unless you have a good reason to do so.
The final point is that this answer relates to film, and not television programmes. TV programmes, particularly for commercial television, have very fixed lengths which must be adhered to.