You must be new to AE. Go get started please check out this tutorial: Basic Workflow
If your rendered video is a different length than your composition then you have not matched the composition settings to the output module or the render settings in the Adobe Media Encoder. You did not follow the proper workflow. Check the comp settings first for duration, frame rate, and frame size. It should be one of the default Square Pixel Presets. If it says Custom in the Preset Field then you're probably doing something wrong.
Next, check the render settings. Make sure that the comp is set to render the entire length of the comp and not just the work area. Until you know exactly what you are doing use one of the standard presets in the Output Module or one of the standard presets in the Adobe Media Encoder for H.264. If you can't find the problem then we need a detailed description of your workflow and your composition and render settings. Screenshots will help. You should also include your OS and version of AE down to the last decimal point.