Some factions really like me and a trade route is possible but they still and repeatedly refuse to trade with me – and other factions are neutral towards me but happily agree to a trade agreement. Can anybody explain the game mechanics the AI uses to determine if they accept or decline an offered trade agreement?
Possibly the most important factor that the AI uses is an unfortunate one: game difficulty. If the difficulty is above normal, the AI will only trade with you on the most favorable terms, and will deny trade relations for no particular reason. If you are playing on a harder difficulty, this might be your problem.