Saul was told that David had gone to Keilah. So Saul said, "God has delivered him into my hand, for he has shut himself in by entering a town that has gates and bars." (1 Samuel 23:7)
Both David and Saul believed that God was with them. Both had been anointed by God to be king. Nevertheless, obviously, the anointing had fallen from Saul and had fallen upon David. The lesson is clear. Whenever there is a conflict between those who call upon the name of the Lord, both will seek not only the favor of God, but also believe that God is with them. Saul believed that God had delivered David into his hand. But we know that God was with David and against Saul. Saul was deceived. Surely God was with Saul. There was no way for David to escape. It was obvious; who could deny it? God denied it and David escaped.
Let us, therefore, not judge by apparent circumstances. Just because things may be going a certain way does not always equate to God being with one or another. We see in part; God sees the whole. "For the Lord does not see as man sees; for man looks at the outward appearance, but the Lord looks at the heart."