Your questions are very broad and thereby related to many processes inside and outside the camera as well
Here some of the Lens related data;
The name of the lens is stored with the image, it is used in PP for standard or custom corrections settings like distortion and vignetting along with camera name for further corrections of sensor related colour issues etc. can be used by Nikon software and third party Adobe Camera Raw etc.
The focal length, exit pupil min, max and shooting aperture values used for metering, Matrix metering and comparison to database of images in camera. stored with image
AF-D and AFS lenses, the approximate distance is used for fill flash and stored with image
AF, AF-D and AFS focal length is stored with image
AFAIK there is no treatment, manipulation, changes or calculations done to the lens data by the camera
CPU in camera corrects for sensor data, colour and the electronics etc.
You can see even more in the Exif file,,,
Since your statemet first was related to lens distortion. The mirror-less Leica SL with it's electronic viewfinder, probably the best in the class, show a distortion corrected image in the viewfinder on the fly, quite impressive to see - But disappointing that the new zoom lens has a lot of distortion,,,