Why are so many science-fiction warships both carriers and heavily armed combatants?
Short answerTheir size and operating environment make the combination more plausible: large spacecraft still need smaller craft for local movement and planetary access, even in settings such as Star Trek that also use transporters.
NotesVery large fictional spacecraft can devote volume to heavy weapons, protection, and smaller attack or utility craft at the same time. Space operations also create destinations that the parent vessel may be unable or unwilling to approach directly, especially planetary surfaces. Star Trek reduces some transport demand through transporter technology, yet its ships still require small craft. Fictional designers can combine roles that compete much more severely for space and weight in historical warships.