Flatworms branched off our side of the animal tree of life very early on. They're on the same side as molluscs, some of whom (cephalopods) are famous for having a more distributed nervous system.
Granted though many/most organs are stateful and somewhat adaptive - in a sense they'll "remember" what happened. Even plants possess that to varying degrees.
Did you know human overies contain neurons? I suppose memories are not stored there :-) but still the fact is rather surprising.