I submitted a paper to two journals, and the first published it, but I agreed to publish in the other; what can I do?
The fault here is yours.

You should never have the same paper be submitted in two different journals at the same time. This is an absolute rule that protects both you as an author and the journal as the publisher from duplication of effort, as well as avoiding situations like this.

If you had wanted to stop the publication in journal X, then you should have sent them a letter clearly retracting your submission. This would have ended the process at journal X, and allowed you to submit the paper to journal Y with a clear conscience.

Now, however, since the paper has been published by journal X, you are stuck. If journal Y publishes your paper, you will have the same article published in two different journals, which is also a violation of ethical standards, and could lead to both copies being retracted by the publisher. So, unfortunately, you are stuck paying the fees to the journal X, and the work you've done to improve the paper with journal Y is now "lost" to the literature.

As has also been pointed out, journal X appears to be quite sketchy, and I would avoid any future contact or involvement with them. But for now, consider this a lesson learned for the future.