Well, I guess you could start by asking, what is 'London', anyway? The 'City of London', or 'Greater London'? But since the question clearly means the latter, I'll just go with that.
London, or Ludenwic, when it passed from Mercia to Wessex certainly wasn't capital. Winchester was, although London was England's largest and wealthiest town even then, as confirmed by a levy imposed in 1018. But it rose to more prominence when the Benedictine abbey of St Peter was built at Westminster, by the orders of Edward the Confessor. Edward, who spent his childhood at Normandy and had some continental leanings, built a royal palace nearby at the same time, on Thorney Island. Shortly after that Edward was succeeded by Harold, who got killed at Hastings, which passed the crown to William. Both kings were crowned at Westminster Abbey.
And William also built his palace and residence there, as well as the Tower of London as his capital stronghold. Reasons would be a) there already was a palace there, and b) London, being a major port city, must have held more appeal for the Norman Kings, as they held quite important lands and titles on the other side of the Channel.
As far as I know, there really wasn't a specific piece of legislature stating so-and-so city is the capital of England in medieval times, and the capital was where the monarch chose to hold court principally. Which was where they lived, hence Westminster in medieval times. Which was also, not considered 'London', as 'London' (meaning the 'City', from the Saxon era Lundenburg), Southwark and Westminster were considered quite separate entities.
So the political capital of Norman England became 'Westminster', where King and Parliament was, which was quite a bit different from 'The City of London' in medieval times. The palace was continually used as royal residence till the Tudor era, when there was a fire nearby, which prompted Henry VIII to move to the Palace of Whitehall, also located in Westminster. Eventually they changed to Buckingham, but the two palace sites, Westminster and Whitehall became synonymous with the seat of Parliament - which was, of course, because they were palaces, and medieval parliament used to meet at the current palace of their time.
And Westminster had city status since 1540, and was historically in Middlesex until 1889, when the County of London was formed. (Though the area around the small 'City' was commonly percieved as London at least since 1598, which we know because John Stow includes Southwark and Westminster in his 'A Survey of London') The two Acts of Union in between make this sort of more complicated, but since the question was specifically England I'll skip on that.
So to wrap it up... there is no legal (de jure) capital of 'England', which certainly doesn't mean that England does not have a capital, of course! Just that it is not specifically designated in writing. While Westminster, which is a city in its own right and is part of Greater London hosts the seat of government, which makes it the de facto capital as it has been since 1066 and all that.
TL:DR; The capital of the Kingdom of England was 'Westminster' at least since 1066, which was only officially part of 'London' since 1899. And as for why the capital was there, Edward the Confessor built a palace there, then William the Conqueror came along, decided it was a nice spot to set up palace, and built his own palace there as well.
sourced from "The Story of London: From its Earliest Origins to the Present Day" / and also from John Stow's 'A Survey of London. Reprinted From the Text of 1603'.
The idea of a 'capital' city isn't one that necessarily strictly applies during the Early Medieval period. Kingship was by necessity essentially itinerant, as the king and his retinue alnost constantly toured the country in order to perform his royal duties. In England, this was facilitated by a series of royal vils and so-called 'farms of one night', royal residences and estates which paid their rent by supporting the royal household as it passed through the region. Cities were more important as prestige sites and centres of economic and civic function than they were necessarily as capitals, and the status of a site could depend entirely on the sovereign. In Offa's Mercia, for example, the 'capital' was Tamworth, however by the reign of Æthelred and Æthelflæd, their priority seems to have moved south to Gloucester, which was significantly redeveloped, and was indeed where Æthelflæd herself was buried in 920. From 907 onwards, however, the prestige site in Mercia seems to have been Chester, which was entirely repaired and reoccupied the Mercians and not only rapidly lead to the proliferation of Mercian resettlement across the Cheshire plain, but also soon outshone London as England's most prominent mint and trade site (admittedly London was still recovering from a major plague at this point).
In Wessex, while Winchester was the closest thing to a nominal capital, and was indeed where Ecgberht and Æthelwulf were buried, the Cerdicing 'family' monastery was in fact at Wimborne Minster, established by St Cuthburga, sister of 7th Century West Saxon king Ine, and neighbouring the royal vil at Kingston Lacy. While Alfred's father and grandfather are buried at Winchester, his brother was buried at Wimborne, and when Æthelwold challenges his cousin Edward for the throne, it's the family site at Wimborne he occupies first.
While London isn't the capital throughout most of the Early Medieval period, it is nonetheless one of the most important economic and prestige sites in England. Alongside nearby Rochester and Canterbury, it's one of the three mint sites of the South East which produce the bulk of English coinage between the 7th and the late 9th Centuries, and of the three, it's by far the most important trade port. It's no great exaggeration to say that the London mint is the central hub of the Mercian economy for most of the 9th Century, and when Ecgberht of Wessex gains temporary overlordship of Mercia in 830, he chooses to issue a London-stamped coinage to celebrate this. I talked a bit in this thread about why England is England and not Sæxland, and how unification was a subtle and ongoing political dance rather than an overt act of domination, which is especially the case compared to the Conquest of 1066. While London had remained ostensibly a Mercian city throughout the 9th Century, 'it had functioned heavily as a prestige site for Alfred of Wessex, especially through the minting of his coinage. It was Alfred's West Saxon army which had defended the wic in 883 and rebuilt the Roman civitas in 886, and London which played host to a council between Alfred and the Mercian leadership (his daughter Æthelflæd, son-in-law Æthelred, and Bishop Wærferth of Worcester) in 890. That Alfred, Æthelred and Æthelflæd were co-signing land grants in London by this time (S346) further illustrates the nebulous nature of the city's 'nationality' and suggests an early 'pan-English' control of the city.
After its recovery from the plague of the 890s (potentially an anthrax outbreak), London's economic recovery is swift, and by the 11th Century it is once again England's leading port. Although Winchester may lay claim to some status as the spiritual capital of Wessex, by the time of the 1066 Conquest it is just one of several provincial 'prestige' capitals, alongside York, Chester, and arguably port cities such as Bristol. London's economic worth and nebulous pan-English position, however, make it an excellent foundation for the expansion of tangible political control by an incoming new elite.
The first town in England that may have been thought of as a ‘capital’ was most likely Colchester. This is where the Romans had set up their main town after the invasion. Archaeologists from The Museum of London now believe that the Romans moved their capital to London after the Boudiccan revolt of 60CE. There are several theories behind why, but some of the most important ones are that it was somewhere that shipping could reach (unlike Colchester) and It was the nearest place to the sea where the Thames could be bridged. There is also the fascinating concept that, as London had not been a pre-Roman hub, it was a definite stamp on the country. London was, for want of a better expression, a ‘new build’ as opposed to an old Celtic settlement being re-used as a Roman base. This was the Romans making a statement. The capital was Roman through and through. Your suggestions about Winchester are correct, it was in fact the capital of Wessex (and therefore England) under King Alfred in 871. At this time the population of London was growing rapidly and it’s position as an economic hub was being cemented, again due to ease of shipping and geographical position. This was, to a certain extent reinforced by periods of Viking rule, when the city became a hub for traders from Scandinavia and other parts of Europe. Winchester remained the capital until the 12th century, after the Norman invasion. Norman control of England was centred around London due to its geographical positioning (again) and wealth. The City of London was given special rights and privileges not shared by other towns, and the defensive structures and Palaces built in the area made it a fairly sensible capital for a kingdom that, at least in the eyes of the ruling classes, stretched across the channel into Northern France. It is important to note that, the change from Winchester to London was not a single wholesale move, but more a gradual event. It’s also worth noting that the power of Winchester was acknowledged in the new capital city. The Bishop of Winchester (who at times played a role almost of prime ministerial status) was given control of a huge swathe of land south of the Thames, and the remains of Winchester Palace still sit just west of the southern end of London Bridge. He was given huge powers and made fortune running brothels and drinking establishments in the area, so much so that up until the late 19th century Prostitutes in London were often referred to as Winchester geese. Hope this goes some way to answer your question. TLDR: Winchester was the capital, but after Wessex lost power the capital gradually moved to London, a richer, bigger and better placed location.