$\newcommand{\Z}{\mathbb{Z}}$Pick primes $p$ and $q$ with $2^{1023} < p < q < 2^{1024}$ and $n = p q > 2^{2047}$, drawing $p$ and $q$ uniformly at random. $n$ is the public key, and $p$ and $q$ are the private key, with which you can quickly compute cube roots modulo $n$. (You can also use $65537^\text{th}$ roots, but $e = 3$ makes the public-key computations faster and makes no difference for security in sensible RSA-based signature and encryption schemes.)
Suppose a ‘signature’ on a message $m \in \Z/n\Z$ is a cube root $s$ of $m$ modulo $n$ so that $s^3 \equiv m \pmod n$, and suppose you ‘encrypt’ a message $m \in \Z/n\Z$ by cubing it giving a ciphertext $c \equiv m^3 \pmod n$ so that ‘decrypting’ $c$ requires computing cube roots modulo $n$. This is what is endearingly called ‘textbook RSA’, though it should more properly be called ‘do you even RSA, bro‽’.
- The signature scheme is itself pathetically broken because I just forged the signature $s = 3$ on the message $m = 27$, and given two signatures $s_0, s_1$ on messages $m_0, m_1$ I can forge the signature $s_0 s_1$ on $m_0 m_1$ by multiplying numbers.
- The encryption scheme is itself pathetically broken because if you try to encrypt a short message, such as a 32-byte secret key, whose encoding as an element $m$ of $\Z/n\Z$ has an integer representative below $\sqrt[3]{n}$, I can just compute the integer cube root of $c$ to recover $m$.
How does using the same key for signature and encryption make it worse, you ask? Suppose you intercepted a ciphertext $c \equiv m^3 \pmod n$ that someone sent to me, and you want to find the message $m$. If you persuade me to sign $c$ as a message, giving the signature $s$ with $s^3 \equiv c \pmod n$, then the signature I reveal to you is $s \equiv m \pmod n$. Oops.
This is not how modern RSA-based signature or encryption schemes work, fortunately.
In modern RSA-based signature schemes (RSASSA-PSS, RSA-FDH), a signature on an octet string $m$ is a pair $(r, s)$ where $r$ is a (possibly empty) uniform random bit string and $s$ is a cube root of $H_0(r, m)$ modulo $n$, for some standard hash function $H_0$ mapping messages to elements of $\Z/n\Z$ over which the attacker has little control.
In modern RSA-based encryption schemes, we either
(a) RSAES-OAEP: pick a short secret session key $k$ uniformly at random, pick a bit string $r$ uniformly at random, and send $c \equiv H_1(r, k)^3 \pmod n$, where $H_1$ is a hash function mapping short strings to elements of $\Z/n\Z$; or
(b) RSA-KEM: pick $x \in \Z/n\Z$ uniformly at random, send $c \equiv x^3 \pmod n$, and derive the short secret session key $k = H_2(x)$, where $H_2$ is a hash function mapping elements of $\Z/n\Z$ to short octet strings.
Then we use $k$ as the secret key for a symmetric-key AEAD to enclose the message.
Since the attacker can't control more than $b$ bits of the output of $H_0$, $H_1$, or $H_2$ without spending at least $2^b$ effort, varying either the message $m$ to be signed or the ciphertext $c$ to be decrypted doesn't help them either to decrypt messages of their choice or to sign any messages they can figure out.
All that said, the lesson here is that the security of a cryptosystem that uses one key for two different purposes—e.g., signing and encrypting, or even two different encryption schemes such as RSAES-PKCS1-v1_5 and RSAES-OAEP—is not determined by independently analyzing each purpose; combining them may have catastrophic consequences, and the composite cryptosystem must be studied in its own right. If you also want to use, say, a verifiable random function with the same key, you have to study it again.