I don't know the right way of analysing this, but it seems to me to have to do with grammatical aspect. The Cambridge Grammar of the English Language (Huddleston and Pullum) interprets English as having two aspects, progressive and non-progressive. (The perfect is not considered to be an aspect; it's treated as a distinct system for various reasons.)
As far as I can tell, the gerund-participle is marked for progressive aspect, while the infinitive is not.
In your examples, the gerund-participle seems to agree in aspect with the form of the verb "do." (I don't know if "agreement" is technically the right term for this.)
I don't know why it has to match like this.
I found a resource about cleft sentences that just states this fact, but doesn't explain it:
In order to make a verb stand out the construction what … do must be
used; different verb forms will be found, according to context.
Infinitives with or without to are possible. If the wh-clause
contains a verb in the progressive aspect the complement also has a
verb in the -ing form:
What they do is dump their products
What I did was (to) call the
What he was trying to do was just earning your trust
–"Cleft sentences"; handout from the website of Università degli Studi di Padova, Dipartimento Dei Beni Culturali
According to this resource, this construction with "what" is often called a "pseudo-cleft" sentence to distinguish it from sentences using the dummy pronoun "it." They may also be called wh-clefts, apparently.
I found another resource, The Pseudo-Cleft Construction in English by F. R. Higgins, which says:
With the progressive, as is well-known, the predicate complement must
have an -ing form, as in (xiii) (their [42a]):
(xiii) What I'm doing is teaching him a lesson.
Unfortunately, I was unable to locate any other mentions of the progressive in this book (I initially had high hopes that it might explain how the construction interacts with the English aspectual system).
Some sources mention that some speakers do use the past participle form in sentences such as "What I had done was watch(ed) TV."
In English, [when a verb phrase is focalized], it can appear either as
a bare infinitive or as a to-infinitive, as shown in (1c). However,
when a progressive -ing form is used in the presuppositional clause,
the focus verb has to be in -ing form as well (6a), and when a
perfective -en form is used in the presuppositional clause, the
focus verb can optionally be in -en form, as in (6b).
(6) a. What I'm doing is patting/*pat/*to pat the cat.
b. What I have done is taken/take/to take a taxi to school.
–"On the Syntactic and Semantic Properties of VP Foci in Pseudocleft Sentences in Japanese", Yuki Ishihara, p. 37
I tried to look up information about the internal grammatical structure of pseudo-cleft sentences, but everything I found looked very complicated.