λόγος and ῥῆμα are different words which may be seen to have overlapping meanings. Yet that does not mean they should be considered synonymous or are interchangeable. This can be seen from passages where both are used.
The two are used in the same verse over 30 times in the Greek translation of the Old Testament (LXX). The first time is in Exodus after the LORD gave the Ten Commandments and spoke to Moses:
Moses came and told the people all the words of the LORD and all the rules. And all the people answered with one voice and said, “All the words that the LORD has spoken we will do.”
(Exodus 24:3 ESV)
וַיָּבֹא מֹשֶׁה וַיְסַפֵּר לָעָם אֵת כָּל־דִּבְרֵי יְהוָה וְאֵת כָּל־הַמִּשְׁפָּטִים וַיַּעַן כָּל־הָעָם קֹול אֶחָד וַיֹּאמְרוּ כָּל־הַדְּבָרִים אֲשֶׁר־דִּבֶּר יְהוָה נַעֲשֶֽׂה׃
The original text has דָּבָר in both places. In the Hebrew language Moses told the people all the words of the LORD and the people responded by saying all the words they will do. However, the LXX uses ῥῆμα to translate the first דָּבָר and then λόγος to translate the second. In Greek the passage becomes:
And Moyses went in and recounted to the people all God's words and statutes. And all the people answered with one voice saying, "All the words the Lord has spoken we will do and heed." NETS
εἰσῆλθεν δὲ Μωυσῆς καὶ διηγήσατο τῷ λαῷ πάντα τὰ ῥήματα τοῦ θεοῦ καὶ τὰ δικαιώματα ἀπεκρίθη δὲ πᾶς ὁ λαὸς φωνῇ μιᾷ λέγοντες πάντας τοὺς λόγους οὓς ἐλάλησεν κύριος ποιήσομεν καὶ ἀκουσόμεθα
The Greek language has the ability to distinguish between specific words, ῥήματα, and all of the words in total, λόγους. So first, Moses (took quite a bit of time to) recount the specific words of the LORD, then people responded "all the words we will do." That is, the people did not repeat all the ῥήματα of the LORD; they said they would do the λόγους of the LORD. As used here, λόγους is made up of the ῥήματα. So logos would mean "The Law" not the individual details of laws, which are rhema.
The New Testament alludes to the giving of the Law and has a similar use of the words:
and a blast of a trumpet, and a sound of words — of which, the ones having heard begged that a word not be added to them. For they were not bearing the thing being commanded: “If even a wild-animal should touch the mountain, it shall be stoned.” (Hebrews 12:19-20 DLNT)
καὶ σάλπιγγος ἤχῳ καὶ φωνῇ ῥημάτων ἧς οἱ ἀκούσαντες παρῃτήσαντο μὴ προστεθῆναι αὐτοῖς λόγον οὐκ ἔφερον γὰρ τὸ διαστελλόμενον κἂν θηρίον θίγῃ τοῦ ὄρους λιθοβοληθήσεται
The use of rhema is analogous to individual sayings and logos (singular) to "The Law" as a whole.
Twice Jesus is recorded using the two together:
The one who rejects me and does not receive my words has a judge; the word that I have spoken will judge him on the last day. (John 12:48 ESV)
ὁ ἀθετῶν ἐμὲ καὶ μὴ λαμβάνων τὰ ῥήματά μου ἔχει τὸν κρίνοντα αὐτόν ὁ λόγος ὃν ἐλάλησα ἐκεῖνος κρινεῖ αὐτὸν ἐν τῇ ἐσχάτῃ ἡμέρᾳ
And I say to you that every useless word which people will speak — they will render an account for it on the day of judgment. For by your words you will be declared-righteous, and by your words you will be condemned (Matthew 12:36-37 DLNT)
λέγω δὲ ὑμῖν ὅτι πᾶν ῥῆμα ἀργὸν ὃ λαλήσουσιν οἱ ἄνθρωποι ἀποδώσουσιν περὶ αὐτοῦ λόγον ἐν ἡμέρᾳ κρίσεως ἐκ γὰρ τῶν λόγων σου δικαιωθήσῃ καὶ ἐκ τῶν λόγων σου καταδικασθήσῃ
In both instances rhema means individual words and logos the sum total of the words. In fact, the first use of logos in Matthew 12:36 is literally "it word" which is translated "an account."
There is one other New Testament use where both are used:
While Peter was still speaking these words, the Holy Spirit fell upon all the ones hearing the message. (Acts 10:44 DLNT)
ἔτι λαλοῦντος τοῦ Πέτρου τὰ ῥήματα ταῦτα ἐπέπεσεν τὸ πνεῦμα τὸ ἅγιον ἐπὶ πάντας τοὺς ἀκούοντας τὸν λόγον
The words (rhema) which Peter spoke are the message (logos) the people heard.
Conclusion
Like Exodus and Acts, both of the singular logos in Corinthians mean the entire word or message:
For to one a word[a] of [b] wisdom is given through the Spirit; and to another, a word of knowledge according-to[c] the same Spirit (1 Corinthians 12:8 DLNT)
a. Or, speech, saying, message, statement. b. That is, characterized by; or, resulting in. c. based on, by way of.
The Spirit gives a singular message of wisdom and a singular message of knowledge (not a single word of wisdom and single word of knowledge).
Matthew, on the other hand, uses the singular rhema in a slightly different way:
And Peter remembered the word Jesus had spoken[a]— that “Before a rooster crows, you will deny Me three-times”. And having gone outside, he wept bitterly. (Matthew 26:75 DLNT)
a. Or, the word of Jesus, who had said that.
Like Exodus and Acts, rhema could be written as plural. In that case it would mean the specific words which Jesus spoke: "Before a rooster crows, you will deny Me three-times." However, rhema is singular. This requires the reader to see one particular word from all those which Jesus spoke.
This effect distinguishes between all of the specific words in order to give attention to just one word which Jesus spoke. The one word is, deny. That is, Peter remembered the word "deny" which Jesus had spoken (once) and which Peter had done (three times).