All brass instruments alter pitch by changing tubing length. They do it in one of two ways.
Use piston or rotary valves to redirect air through additional tubing segments.
Use a telescoping slide to physically lengthen/shorten the tubing.
The trumpet is valved, not slide. The trombone is the primary modern slide instrument. Valve trombones exist (3 valves, no slide)—a hybrid subset used in opera bands, some jazz, and marching contexts where slide logistics are impractical.
Both achieve the same goal (chromatic pitch control) through fundamentally different mechanical philosophies. The music each enables reflects that difference.