There is a great writeup on this in the wonderful book "Development of the Space Shuttle 1972-1981" by T. R. Heppenheimer. Highly recommended, as is his prior volume "The Space Shuttle Decision".
tl;dr: They did melt/burn. That was the whole idea.
Page 178-179:
Nozzle: The flame within a solid motor burned at 5,700 degrees
Fahrenheit, which was hot enough to boil iron. What was to prevent it
from destroying the booster? A liquid-fuel engine relied on
regenerative cooling, as it circulated hydrogen through numerous small
tubes or channels, but this was out of the question with solid
propellants. Insulation helped, it protected the casing as the flame
front approached the wall. The nozzles of large solid motors relied on
a third approach, for they were lined with thick slabs of ablative
material. Like a reentering nose cone, this ablative layer could
slowly decompose, vaporize, and erode as the burning proceeded.
For the SRB nozzle, the basic ablative material was carbon cloth
phenolic, a cloth woven of carbon fiber and strongly impregnated with
phenolic resin. It cost thirty dollars per pound, and each SRB used
it by the ton. Layers of this substance protected the throat as well
as other regions that faced the full severity of the hot gas flow.
Silica cloth phenolic, woven from silica fibers, protected parts where the
thermal environment was less demanding. Glass cloth phenolic served as
insulation.
These materials came from vendors in the form of tape, with widths
from three-fourths of an inch to thirteen inches. Rolls of tape fed a
wrapping machine that laid the tape in plies on a rotating mandrel. A
blast of hot air, at temperatures up to 700 degrees Fahrenheit, softened
the resin. A roller pressed the tape against the substrate, with a force of up to three hundred pounds for each inch of tape width. After rotating past the roller, the tape was exposed to a flow of carbon dioxide at -60 degrees. This prevented the resin from curing and produced a hard, solid surface as a substrate for the next ply.
Each nozzle used five tons of carbon cloth phenolic, two tons of glass
phenolic, and one ton of silica phenolic, all tape-wrapped in this
fashion. Finished carbon lay-ups were cured in a hydroclave, which
used water to apply heat and pressure. Other lay-ups went into an
autoclave, which used carbon dioxide. Cured components were machined
using diamond cutting tools, achieving tolerances as close as 0.0025
inches.
To achieve thrust vector control, the nozzle was to swivel by up to
7.1 degrees in pitch and yaw. Designers avoided the use of sliding surfaces, which could prove difficult to seal against leaks of hot
gas. Instead they used a flexible support or bearing, built from ten
steel plates interleaved with eleven layers of rubber. Similar flexible
bearings had flown previously, but this was the largest ever built.
Within the hot gas flow path, the bearing lay in what amounted to a
backwater, removed from the full force of this exhaust. Nevertheless,
some gas would reach it, which meant that that this flexible support
needed flexible thermal protection. It obtained this from a "boot", a
barrier of laminated rubber that eroded or burned away at a calculated
rate and that was thick enough to hold out until the motor expended
all of its propellant.