People in the UK (who are not subject to immigration control or other restrictions) do not have to carry any form of identification.
This doesn't answer all parts of your question, but s164 Road Traffic Act 1988 is appropriate to the part about driving.
a person driving a motor vehicle on a road ... must, on being so required by a constable or vehicle examiner, produce his licence and its counterpart1 for examination, so as to enable the constable or vehicle examiner to ascertain the name and address of the holder of the licence, the date of issue, and the authority by which they were issued. (s164(1))
So it makes no difference why you were stopped: a constable or traffic offiver can demand production of your licence if you were driving. The same power exists if you're suspected of having caused an accident or committed an offence, even if you're not driving at the time of the production demand.
Non-production is an offence:
If a person required under the preceding provisions of this section to produce a licence and its counterpart ... fails to do so he is, subject to subsections (7) to (8A) below, guilty of an offence. (s164(6))
However, it is a defence to produce the licence (or a receipt for a licence) within seven days of the demand (s164(7-8)). In practice, the officer will give you a 'producer' requiring you to present your licence at a police station within seven days, after which you will be guilty of the non-production offence. The implication of this is that it is not required that you carry your licence; merely that you have it available to produce within seven days.
1 Presumably the reference to 'counterpart' will go away when the counterpart is abolished on 8th June 2015.