HEX is the shorthand designers and CSS use; RGB is what most programming interfaces, canvas APIs and design tool inputs expect. They describe exactly the same colour in different notation, so converting between them is lossless and exact.
Each digit is doubled, so #f0a expands to #ff00aa. It is a convenience that only works when both digits of every channel happen to match, which is why not every colour has a short form.
Each pair is one byte, from 00 to ff, giving 0 to 255 in decimal for red, green and blue respectively. So #3b82f6 is red 59, green 130, blue 246.
The final pair is alpha, the opacity channel, again from 00 to ff. That maps to the fourth value in an rgba() colour, expressed there as a decimal from 0 to 1.
None. Both notations describe the same 24-bit colour space, so conversion in either direction is exact and fully reversible.