Both scriptures describe tricky scenarios, situations in which they were vulnerable and weak. At one point or the other, everyone needs help. In times like this, you are most vulnerable and likely to do just about anything to get relief.
Matthew 4:1-4 tells us that there were weak moments in even Jesus' life. The devil always tries to take advantage of such moments and pushes us to compromise. It is important to note that there is always a price to pay for any agreement you make with the devil, no matter how fruitful it seems. The Christian will always have the final word, because of the Holy Spirit at work in us. 2 Corinthians 4:8 comforts us with the promise that God will have the final say.
No matter how difficult the situation is, do not compromise your God-given right. Wait for God's redemption. The Lord gives wisdom to escape any situation and strengthens us when we are weak. The Lord will come through for you, just continue to wait on him.