There are a few different ways that you can enable windowed mode for Kotor. The first way is to go into the game's installation folder and find the file called swkotor.ini. Once you have opened this file, find the line that says FullScreen=1 and change the 1 to a 0. Save your changes and exit the file. When you start up the game, it should now be in windowed mode.
The second way to enable windowed mode is to use a mod. There are a few different mods out there that will allow you to play Kotor in windowed mode, but they all work pretty much the same way. Download and install the mod of your choice, then launch Kotor from its shortcut. A new window should pop up allowing you to select what resolution you want to play at and whether or not you want fullscreen enabled. Make your selections and hit OK, and the game should start up in windowed mode.
Whichever method you choose, playing Kotor in windowed mode can make for a much more pleasant experience. No more getting distracted by other things going on outside of the game, and no more having to alt-tab every time you want to check something else!