Both constructions seem capable of expressing 'I thought something very recently'. Why is the former preferred over the latter?
Because thinking is an action that takes time, and is thus suited to be used with a continuous present. "I was just thinking" means that you were in the continuous process of thinking about it. See: Difference between (was thinking / thought / have thought / had thought)