[subject] + 不禁 + [verb phrase]
[subject] + 不由得 + [verb phrase]
不由得 + [person] + 不 + [verb]
不禁 and 不由得 go before a verb and say the subject reacted without meaning to – laughing, sighing, remembering – because of something just seen or heard. The trigger usually comes in the first clause. 禁 is read jīn here. 不禁 is written and a little literary; 不由得 works in speech too.
The verbs that follow are reactions: 笑, 哭, 想起, 感叹, 担心, 紧张起来, 流下眼泪.
不由得 has a second use that 不禁 lacks. With a person and a negative verb after it, it means "leaves someone no choice but to".
Both sit after the subject, never before it. And both describe a single reaction in the moment, not a habit you fight against – for that, use 忍不住.