College goes back to the Latin collegium, which in an abstract sense meant partnership, collegiality and in a more concrete sense meant a body of colleagues or partners. In its earliest use in English it meant a body of persons organised to perform some function in common and (usually) given legal recognition and privileges for the purpose. The purpose of a college was not necessarily educational. In fact, at first it was mostly ecclesiastical; Wyclif referred to Christ and the twelve apostles as a college and, in ecclesiastical usage, we still have the college of cardinals. Then there’s the electoral college, of course. And you have professional bodies concerned with regulating standards like the Royal College of Physicians. They may in fact offer professional training, and if they don’t they may still conduct examinations, but neither of these activities are essential to their being colleges.
Increasingly, though, the name came to be applied to bodies of people organised for educational purposes, and this is the predominant meaning today. In general a charter or similar instrument issued by the government both formally organised the members of the college and conferred functions and privileges on the organised body. The term “college” came to refer to a body organised and privileged in this way, as opposed to in some less formal way. Thus Eton College, a secondary school for boys, was chartered by King Henry VI in 1440. It neither grants degrees nor prepares students for degrees granted by other bodies. New College, Oxford was established by the Bishop of Winchester in 1379. The name “college” in each case points not to the kind of education provided by the institution concerned, but to the way it has been organised, constituted and privileged by a higher authority.
University, by contrast, was always used – in English - in a specifically educational context. It comes from a Latin word which originally mean entirety, universe but by medieval times it had come to refer specifically to the collective entirety of a society or community. From there it passed into French and, by the time it made the transition to English (by about 1300) it referred to the entirety of an educational community. But it was only used for fairly large educational communities, which generally included smaller but still formally organised bodies. Thus a university would tend to embrace a number of colleges (in the educational sense), but it would also embrace other institutions, informal groupings and individuals. And it wasn’t absolutely essential that the various lesser entities which it embraced would necessarily include colleges, though I suspect in practice it always did, at least until fairly recently.
In general, then, a university is a larger and somewhat looser institution than a college, and it usually but not necessarily includes at least one college. Some institutions, founded as colleges, grow to a size and diversity which makes them effectively indistinguishable from other institutions with the name of university. This may lead to a change in title with or without some kind of structural reorganisation (as Harvard College at some point gave rise to Harvard University, and Trinity College Dublin gave rise to Dublin University) or it may not (as in the William and Mary College example cited above). There is probably a fair spread of institutions which are called Colleges and which are divided into Departments, which could easily retitle their Departments as Colleges and the overall institution as a University, while making no change of substance to the character of the institution.