Depends on the type of section really. Each has different purposes. (This is really simplified and im sure someone will come along and tell me ive got bits wrong)
Theres several shorter sections that allow you to hold people in order to ask the mental health team to assess them. This includes ones for nurses and drs to hold you for example in a+e to await a psychiatrist (and specially approved doctors and clinicians) who can assess you under the act. This also includes the police powers to detain someone in public such a 136. If it is deemed by the 2 drs and an amhp that they need further detention then there are further types of section
A section 2 is the 28 day one you are probably thinking of. The purpose of a section 2 should normally be to assess someone, eg someone who hasnt got an existing diagnosis.
Section 3 is longer and is for treatment and comes with more ability to do things such as complete medication changes against someones will.
You can renew a section (normally a section 3 as otherwise you'd have to explain why you failed to complete the assesment in a given time frame), and people in longer term placements may for example beheld longer. You shouldn't automatically renew an assement and theres lots of checks in place such as getting external drs in, and various types of hearings and tribunals to check you arent holding people unnecessarily (to prevent situations like asylums) Theres obviously also forensic sections
All of the sections are an "up to" and most people in my experience are discharged before the time frame. Hospitals now are seen as a short place for stablisation in acute illness, and that most of your recovery is expected to be held in the community. In my old trust we had an aim for a roughly average stay of 14 days where possible but some people were in for much more, some much less.
Someone with suicidal thoughts for example wouldnt be expected to have 0 thoughts of harming themselves but would typically discharged when they felt these were managable as the effective treatment of therapies etc is long term and community based
A bit like if you were admitted with a physical issue, they would do short term fixes such as change your meds, drips etc but your longer term treatment would be within specialist outpatient where possible, even when the condition is serious like awaiting a kidney transplant