Biblical commentators offer a few different options as to what exactly "mammon" refers to in the Bible.
The word “mammon” appears only a few times in the entire Bible, and yet it is among the most interesting words in Scripture. Jesus is quoted using the word in the Gospels of both Matthew and Luke.
No one can serve two masters. He will either hate one and love the other, or be devoted to one and despise the other. You cannot serve God and mammon.Matthew 6:24
In the Gospel of Luke, this sentence is preceded by a discussion of “dishonest wealth,” where Jesus says, “If, therefore, you are not trustworthy with dishonest wealth, who will trust you with true wealth?” (Luke 16:11)
Most commentators believe the term refers to wealth in a general sense.
Scott Hahn, in the Ignatius Catholic Study Bible, explains that “mammon” is, “an Aramaic word meaning ‘wealth.'”
This definition of the word appears to fit in the context of the passage, where Jesus is explaining that “wealth” cannot be our master. Only God should be our master, and wealth should be seen as secondary.
Some medieval commentators argued that “mammon” is personified and was a pagan god.
The Catholic Encyclopedia states that, “Mammon is personified, hence the prevalent notion, emphasized by Milton, that Mammon was a deity… Mammon was commonly regarded as a deity in the Middle Ages; thus Peter Lombard says, ‘Riches are called by the name of a devil, namely Mammon, for Mammon is the name of a devil, by which name riches are called according to the Syrian tongue.'”
There is no concrete evidence that anyone worshipped a pagan deity called Mammon, but to say “You cannot serve both God and [the devil]” would be a true statement.
In this way, the term “mammon” is often replaced with various worldly notions of wealth or temporal power by preachers who are trying to explain Jesus’ words in a modern context.
The key to understand it all is that Jesus wants us to serve God as our only master, using his created world in his service.