How exactly does analogRead() function work? Does it only take voltage as an input? And then converting that into a number from 0-1023 through some mechanism and outputting that to us? Some insight would be greatly appreciated!

The Holy Datasheet

Section 24

Everything you would ever want to know (that is not in the datasheet)...