沾光 (zhānguāng) means 'to benefit from someone else's good fortune or connections.' 沾边 (zhānbiān) means 'to be relevant to; to have something to do with.'
mistakes
Don't confuse 沾 (zhān, to moisten/stain) with 粘 (zhān/nián, to stick/adhere). 沾 is about liquid contact or getting something on a surface; 粘 is about sticking together.
The water radical anchors the meaning — 沾 is originally about water contact: getting wet, soaking up moisture, leaving a damp mark. From literal water-stains came metaphorical 'staining' (catching habits or disease) and 'touching' (only the lightest contact, like dipping a finger).
Right component supplies the sound — exact match: zhān. 占 has two readings (zhān divine, zhàn occupy) but here only the zhān reading matters. Same phonetic in 站 (zhàn, stand), 战 (zhàn, war), 粘 (zhān/nián, sticky), 帖 (tiè, note).