Have been posting about this a lot recently. The ideal is to get it from the company. But sometimes the company doesn't respond and so they look for alternative means to confirm the employment. There's various ways they can approach that - getting a more personal reference from someone reputable to confirm your employment at that time (e.g. a colleague) or for you to provide documentation that confirms the employment did happen.
This recently happened with me and a recruitment agency I had worked through. They said they had no record of me which was crazy! So I provided the reference check company with correspondence that confirmed the contract (which confirmed the agency should know who I was) and bank statements to show the period of time I had been paid by them (which demostrates length of service beyond the initial contract).
Ultimately how much a reference check company/team will place on how important that specific information is depends on your profile and the experience they are struggling to get the details from. If it is a more substanital piece of work experience, in a more comparable employer setting, more recent, or a job that is more comparable to the one you are applying to, they will care about it more and will strive to get full details/confirmation of it. With my example above, it was 5 and a half years ago, and although substantial in other ways (9-10 months, very senior role/experience), the reference company had received all my other references for the past 7 years with no problems and everything else added up. And so when I could show the agency employed me for at least 9 months based on the payments received into my bank account, and provided the signed contract I had, the reference company didn't really care that the agency didn't provide a reference. It might have been different if that was my only employment.